summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann Friedrichs <johann.friedrichs@web.de>2018-03-21 12:14:55 +0100
committerJohann Friedrichs <johann.friedrichs@web.de>2018-03-21 12:14:55 +0100
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) {
- if (!eq(s1[i],s2[i])) {
- return lt(s1[i],s2[i])?-1:1;
+ for (std::size_t i = 0; i < n; ++i) {
+ if (!eq(s1[i], s2[i])) {
+ return lt(s1[i], s2[i]) ? -1 : 1;
}
}
return 0;
@@ -235,8 +237,8 @@ char_traits<char>
// search c in s
static const char* find(const char* s, std::size_t n,
const char& c) {
- for (std::size_t i=0; i<n; ++i) {
- if (eq(s[i],c)) {
+ for (std::size_t i = 0; i < n; ++i) {
+ if (eq(s[i], c)) {
return &(s[i]);
}
}
@@ -245,27 +247,32 @@ char_traits<char>
};
// define a special type for such strings
-typedef std::basic_string<char,ignorecase_traits> icstring;
+typedef std::basic_string<char, ignorecase_traits> icstring;
// --- eTimerMod -------------------------------------------------------------
-enum eTimerMod { tmNoChange=0, tmStartStop=1, tmFile=2, tmAuxEventID=4 };
+enum eTimerMod { tmNoChange = 0, tmStartStop = 1, tmFile = 2, tmAuxEventID = 4 };
// --- cCommands -------------------------------------------------------------------
-class cCommand : public cListObject {
+class cCommand : public cListObject
+{
private:
- char *title;
- char *command;
- bool confirm;
- static char *result;
+ char *title;
+ char *command;
+ bool confirm;
+ static char *result;
public:
- cCommand(void);
- virtual ~cCommand();
- bool Parse(const char *s);
- const char *Title(void) { return title; }
- bool Confirm(void) { return confirm; }
- const char *Execute(const char *Parameters = NULL);
- };
+ cCommand(void);
+ virtual ~cCommand();
+ bool Parse(const char *s);
+ const char *Title(void) {
+ return title;
+ }
+ bool Confirm(void) {
+ return confirm;
+ }
+ const char *Execute(const char *Parameters = NULL);
+};
class cCommands : public cConfig<cCommand> {};
diff --git a/log.h b/log.h
index 3eff222..27be3ea 100644
--- a/log.h
+++ b/log.h
@@ -30,70 +30,67 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
class cLogFile: public cFile
{
- public:
+public:
static int loglevellimit;
- void Open(const char* filename, const char* version)
- {
- if (loglevellimit == 0) return;
- if (!cFile::Open(filename, O_CREAT|O_APPEND|O_WRONLY))
- esyslog("EPGSEARCH: could not open log file: %s", filename);
- Log(1, "---------------------------------------", loglevellimit);
- Log(1, "EPGSearch log started (verbose level %d, version %s)", loglevellimit, version);
- }
- void Log(int LogLevel, const char *text, ...)
- {
- if (LogLevel > loglevellimit) return;
- if(IsOpen())
- {
- char* buffer = NULL;
- va_list Arg;
- va_start(Arg,text);
- if (vasprintf(&buffer, text, Arg) < 0)
- esyslog("EPGSearch: vasprintf error");
- va_end(Arg);
- time_t now = time(NULL);
-
- char datebuf[32];
- struct tm tm_r;
- tm *tm = localtime_r(&now, &tm_r);
-
- char *p = stpcpy(datebuf, WeekDayName(tm->tm_wday));
- *p++ = ' ';
- strftime(p, sizeof(datebuf) - (p - datebuf), "%d.%m.%Y", tm);
-
- char timebuf[25];
- strftime(timebuf, sizeof(timebuf), "%T", localtime_r(&now, &tm_r));
-
- cString log = cString::sprintf("%s %s: %s\n", datebuf, timebuf, buffer);
- free(buffer);
- safe_write(*this, log, strlen(log));
- }
- }
- void eSysLog(const char *text, ...)
- {
- char* buffer = NULL;
- va_list Arg;
- va_start(Arg,text);
- if (vasprintf(&buffer, text, Arg) < 0)
- esyslog("EPGSearch: vasprintf error");
- va_end(Arg);
- esyslog("EPGSearch: %s", buffer);
- Log(1, "%s", buffer);
- free(buffer);
- }
- void iSysLog(const char *text, ...)
- {
- char* buffer = NULL;
- va_list Arg;
- va_start(Arg,text);
- if (vasprintf(&buffer, text, Arg) < 0)
- esyslog("EPGSearch: vasprintf error");
- va_end(Arg);
- isyslog("EPGSearch: %s", buffer);
- Log(1, "%s", buffer);
- free(buffer);
- }
- int Level() { return loglevellimit; }
+ void Open(const char* filename, const char* version) {
+ if (loglevellimit == 0) return;
+ if (!cFile::Open(filename, O_CREAT | O_APPEND | O_WRONLY))
+ esyslog("EPGSEARCH: could not open log file: %s", filename);
+ Log(1, "---------------------------------------", loglevellimit);
+ Log(1, "EPGSearch log started (verbose level %d, version %s)", loglevellimit, version);
+ }
+ void Log(int LogLevel, const char *text, ...) {
+ if (LogLevel > loglevellimit) return;
+ if (IsOpen()) {
+ char* buffer = NULL;
+ va_list Arg;
+ va_start(Arg, text);
+ if (vasprintf(&buffer, text, Arg) < 0)
+ esyslog("EPGSearch: vasprintf error");
+ va_end(Arg);
+ time_t now = time(NULL);
+
+ char datebuf[32];
+ struct tm tm_r;
+ tm *tm = localtime_r(&now, &tm_r);
+
+ char *p = stpcpy(datebuf, WeekDayName(tm->tm_wday));
+ *p++ = ' ';
+ strftime(p, sizeof(datebuf) - (p - datebuf), "%d.%m.%Y", tm);
+
+ char timebuf[25];
+ strftime(timebuf, sizeof(timebuf), "%T", localtime_r(&now, &tm_r));
+
+ cString log = cString::sprintf("%s %s: %s\n", datebuf, timebuf, buffer);
+ free(buffer);
+ safe_write(*this, log, strlen(log));
+ }
+ }
+ void eSysLog(const char *text, ...) {
+ char* buffer = NULL;
+ va_list Arg;
+ va_start(Arg, text);
+ if (vasprintf(&buffer, text, Arg) < 0)
+ esyslog("EPGSearch: vasprintf error");
+ va_end(Arg);
+ esyslog("EPGSearch: %s", buffer);
+ Log(1, "%s", buffer);
+ free(buffer);
+ }
+ void iSysLog(const char *text, ...) {
+ char* buffer = NULL;
+ va_list Arg;
+ va_start(Arg, text);
+ if (vasprintf(&buffer, text, Arg) < 0)
+ esyslog("EPGSearch: vasprintf error");
+ va_end(Arg);
+ isyslog("EPGSearch: %s", buffer);
+ Log(1, "%s", buffer);
+ free(buffer);
+ }
+ int Level() {
+ return loglevellimit;
+ }
static char *LogFileName;
};
diff --git a/mail.c b/mail.c
index a5f815c..c2ec04d 100644
--- a/mail.c
+++ b/mail.c
@@ -61,11 +61,11 @@ string cMailTimerNotification::Format(const string& templ) const
result = varExprTimer.Evaluate(pTimer);
if (timerMod == tmStartStop)
- result = ReplaceAll(result, "%timer.modreason%", tr("Start/Stop time has changed"));
+ result = ReplaceAll(result, "%timer.modreason%", tr("Start/Stop time has changed"));
if (timerMod == tmFile)
- result = ReplaceAll(result, "%timer.modreason%", tr("Title/episode has changed"));
+ result = ReplaceAll(result, "%timer.modreason%", tr("Title/episode has changed"));
else
- result = ReplaceAll(result, "%timer.modreason%", "");
+ result = ReplaceAll(result, "%timer.modreason%", "");
return result;
}
@@ -81,19 +81,18 @@ const cEvent* cMailTimerNotification::GetEvent() const
bool cMailTimerNotification::operator< (const cMailTimerNotification &N) const
{
LOCK_CHANNELS_READ;
- const cChannel* channel = Channels->GetByChannelID(channelID,true,true);
- const cChannel* channelOther = Channels->GetByChannelID(N.channelID,true,true);
+ const cChannel* channel = Channels->GetByChannelID(channelID, true, true);
+ const cChannel* channelOther = Channels->GetByChannelID(N.channelID, true, true);
if (!channel || !channelOther)
- return false;
+ return false;
const cEvent* event = GetEvent();
const cEvent* eventOther = N.GetEvent();
- if (event && eventOther) // sort event by start time and channel
- {
- if (event->StartTime() == eventOther->StartTime())
- return channel->Number() < channelOther->Number();
- else
- return event->StartTime() < eventOther->StartTime();
- }
+ if (event && eventOther) { // sort event by start time and channel
+ if (event->StartTime() == eventOther->StartTime())
+ return channel->Number() < channelOther->Number();
+ else
+ return event->StartTime() < eventOther->StartTime();
+ }
return false;
}
@@ -123,14 +122,14 @@ cMailDelTimerNotification::cMailDelTimerNotification(const string& Formatted, tC
bool cMailDelTimerNotification::operator< (const cMailDelTimerNotification &N) const
{
LOCK_CHANNELS_READ;
- const cChannel* channel = Channels->GetByChannelID(channelID,true,true);
- const cChannel* channelOther = Channels->GetByChannelID(N.channelID,true,true);
+ const cChannel* channel = Channels->GetByChannelID(channelID, true, true);
+ const cChannel* channelOther = Channels->GetByChannelID(N.channelID, true, true);
if (!channel || !channelOther)
- return false;
+ return false;
if (channel != channelOther)
- return channel->Number() < channelOther->Number();
+ return channel->Number() < channelOther->Number();
else
- return (start < N.start);
+ return (start < N.start);
}
// ----------------------
@@ -147,17 +146,17 @@ string cMailAnnounceEventNotification::Format(const string& templ) const
result = ReplaceAll(result, "%searchid%", NumToString(searchextID));
cSearchExt* search = SearchExts.GetSearchFromID(searchextID);
if (search)
- result = ReplaceAll(result, "%search%", search->search);
+ result = ReplaceAll(result, "%search%", search->search);
return result;
}
// -------------
// cMailNotifier
cMailNotifier::cMailNotifier(string Subject, string Body)
-: subject(Subject), body(Body)
+ : subject(Subject), body(Body)
{
- if (subject.size() > 0)
- SendMail(true);
+ if (subject.size() > 0)
+ SendMail(true);
}
bool cMailNotifier::SendMailViaSendmail()
@@ -171,16 +170,16 @@ bool cMailNotifier::SendMailViaSendmail()
snprintf(mailcmd, sizeof(mailcmd), mailargs, mailproc, to.c_str());
if (!(mail = popen(mailcmd, "w"))) {
- return false;
+ return false;
}
fprintf(mail, "From: VDR\n");
fprintf(mail, "To: %s\n", to.c_str());
fprintf(mail, "Subject: %s\n", subject.c_str());
if (FindIgnoreCase(body, "<html>") >= 0)
- fprintf(mail, "Content-Type: text/html; charset=%s\n", GetCodeset().c_str());
+ fprintf(mail, "Content-Type: text/html; charset=%s\n", GetCodeset().c_str());
else
- fprintf(mail, "Content-Type: text/plain; charset=%s\n", GetCodeset().c_str());
+ fprintf(mail, "Content-Type: text/plain; charset=%s\n", GetCodeset().c_str());
fprintf(mail, "\n");
@@ -196,10 +195,9 @@ bool cMailNotifier::SendMailViaScript()
// create a temporary file for the message body
string filename = *AddDirectory(CONFIGDIR, "epgsearchmail.temp");
std::ofstream bodyfile(filename.c_str());
- if (!bodyfile)
- {
- LogFile.eSysLog("error opening file %s", filename.c_str());
- return false;
+ if (!bodyfile) {
+ LogFile.eSysLog("error opening file %s", filename.c_str());
+ return false;
}
bodyfile << body;
bodyfile.close();
@@ -207,40 +205,37 @@ bool cMailNotifier::SendMailViaScript()
string AuthUser = EPGSearchConfig.MailAuthUser;
string AuthPass = EPGSearchConfig.MailAuthPass;
string cmdArgs =
- string(" -f \"VDR <") + EPGSearchConfig.MailAddress + ">\"" +
- " -t " + EPGSearchConfig.MailAddressTo +
- " -s " + EPGSearchConfig.MailServer +
- " -u \"" + subject + "\""+
- (EPGSearchConfig.MailUseAuth?
- (AuthUser != "" ?(" -xu " + AuthUser):"") +
- (AuthPass != "" ?(" -xp " + AuthPass):"")
- :"") +
- " -o message-charset=" + GetCodeset() +
- " -o message-file=" + filename;
+ string(" -f \"VDR <") + EPGSearchConfig.MailAddress + ">\"" +
+ " -t " + EPGSearchConfig.MailAddressTo +
+ " -s " + EPGSearchConfig.MailServer +
+ " -u \"" + subject + "\"" +
+ (EPGSearchConfig.MailUseAuth ?
+ (AuthUser != "" ? (" -xu " + AuthUser) : "") +
+ (AuthPass != "" ? (" -xp " + AuthPass) : "")
+ : "") +
+ " -o message-charset=" + GetCodeset() +
+ " -o message-file=" + filename;
bool success = ExecuteMailScript(cmdArgs);
if (remove(filename.c_str()) != 0)
- LogFile.eSysLog("error deleting file %s", filename.c_str());
+ LogFile.eSysLog("error deleting file %s", filename.c_str());
return success;
}
bool cMailNotifier::SendMail(bool force)
{
- time_t nextMailDelivery = EPGSearchConfig.lastMailOnSearchtimerAt + EPGSearchConfig.sendMailOnSearchtimerHours*60*60;
- if (time(NULL) > nextMailDelivery || force)
- {
- if (!EPGSearchConfig.mailViaScript)
- return SendMailViaSendmail();
- else
- return SendMailViaScript();
- }
- else
- {
-
- LogFile.Log(2, "mail delivery delayed until %s", DAYDATETIME(nextMailDelivery));
- return false;
+ time_t nextMailDelivery = EPGSearchConfig.lastMailOnSearchtimerAt + EPGSearchConfig.sendMailOnSearchtimerHours * 60 * 60;
+ if (time(NULL) > nextMailDelivery || force) {
+ if (!EPGSearchConfig.mailViaScript)
+ return SendMailViaSendmail();
+ else
+ return SendMailViaScript();
+ } else {
+
+ LogFile.Log(2, "mail delivery delayed until %s", DAYDATETIME(nextMailDelivery));
+ return false;
}
}
@@ -249,19 +244,18 @@ bool cMailNotifier::ExecuteMailScript(string ScriptArgs)
string mailCmd = MailCmd;
LogFile.Log(3, "starting mail script: %s with parameters: %s", mailCmd.c_str(), ScriptArgs.c_str());
if (mailCmd == "sendEmail.pl") // beautify output for standard script
- ScriptArgs += " | cut -d\" \" -f 6-";
+ ScriptArgs += " | cut -d\" \" -f 6-";
cCommand cmd;
string fullcmd = "mailcmd: " + mailCmd;
- if (!cmd.Parse(fullcmd.c_str()))
- {
- LogFile.eSysLog("error parsing cmd: %s", MailCmd.c_str());
- return false;
+ if (!cmd.Parse(fullcmd.c_str())) {
+ LogFile.eSysLog("error parsing cmd: %s", MailCmd.c_str());
+ return false;
}
const char* res = cmd.Execute(ScriptArgs.c_str());
- scriptReply = res?res:"";
+ scriptReply = res ? res : "";
if (scriptReply != "")
- LogFile.iSysLog("mail cmd result: %s", scriptReply.c_str());
+ LogFile.iSysLog("mail cmd result: %s", scriptReply.c_str());
return true;
}
@@ -269,12 +263,12 @@ bool cMailNotifier::ExecuteMailScript(string ScriptArgs)
bool cMailNotifier::TestMailAccount(string MailAddressTo, string MailAddress, string MailServer, string AuthUser, string AuthPass)
{
string cmdArgs =
- string("-v -f \"VDR <") + MailAddress + ">\"" +
- " -t " + MailAddressTo +
- " -s " + MailServer +
- " -u \"VDR-Testmail\"" +
- (AuthUser != "" ?(" -xu " + AuthUser):"") +
- (AuthPass != "" ?(" -xp " + AuthPass):"") +
+ string("-v -f \"VDR <") + MailAddress + ">\"" +
+ " -t " + MailAddressTo +
+ " -s " + MailServer +
+ " -u \"VDR-Testmail\"" +
+ (AuthUser != "" ? (" -xu " + AuthUser) : "") +
+ (AuthPass != "" ? (" -xp " + AuthPass) : "") +
" -m \"Success! ;-)\"";
return ExecuteMailScript(cmdArgs);
@@ -284,23 +278,20 @@ string cMailNotifier::LoadTemplate(const string& templtype)
{
string filename = *AddDirectory(CONFIGDIR, templtype.c_str());
string templ = "";
- if (filename != "" && access(filename.c_str(), F_OK) == 0)
- {
- LogFile.iSysLog("loading %s", filename.c_str());
- FILE *f = fopen(filename.c_str(), "r");
- if (f)
- {
- templ = "";
- char *s;
- cReadLine ReadLine;
- while ((s = ReadLine.Read(f)) != NULL)
- {
- if (strlen(s) > 0 && s[0] == '#')
- continue;
- templ += string(s) + "\n";
- }
- fclose(f);
- }
+ if (filename != "" && access(filename.c_str(), F_OK) == 0) {
+ LogFile.iSysLog("loading %s", filename.c_str());
+ FILE *f = fopen(filename.c_str(), "r");
+ if (f) {
+ templ = "";
+ char *s;
+ cReadLine ReadLine;
+ while ((s = ReadLine.Read(f)) != NULL) {
+ if (strlen(s) > 0 && s[0] == '#')
+ continue;
+ templ += string(s) + "\n";
+ }
+ fclose(f);
+ }
}
return templ;
}
@@ -334,10 +325,10 @@ void cMailUpdateNotifier::AddNewTimerNotification(tEventID EventID, tChannelID C
void cMailUpdateNotifier::AddModTimerNotification(tEventID EventID, tChannelID ChannelID, uint timerMod)
{
- if (timerMod == tmNoChange || timerMod == tmAuxEventID) // if anything but the eventID has changed
- return;
- cMailTimerNotification N(EventID, ChannelID, timerMod);
- modTimers.insert(N);
+ if (timerMod == tmNoChange || timerMod == tmAuxEventID) // if anything but the eventID has changed
+ return;
+ cMailTimerNotification N(EventID, ChannelID, timerMod);
+ modTimers.insert(N);
}
void cMailUpdateNotifier::AddRemoveTimerNotification(const cTimer* t, const cEvent* e)
@@ -355,38 +346,36 @@ void cMailUpdateNotifier::AddRemoveTimerNotification(const string& Formatted, tC
void cMailUpdateNotifier::AddAnnounceEventNotification(tEventID EventID, tChannelID ChannelID, int SearchExtID)
{
- cMailAnnounceEventNotification N(EventID, ChannelID, SearchExtID);
- announceEvents.insert(N);
+ cMailAnnounceEventNotification N(EventID, ChannelID, SearchExtID);
+ announceEvents.insert(N);
}
void cMailUpdateNotifier::SendUpdateNotifications()
{
// insert pending notifications
cPendingNotification* p = PendingNotifications.First();
- while (p)
- {
- if (p->type == 0)
- AddNewTimerNotification(p->eventID, p->channelID);
- else if (p->type == 1)
- AddModTimerNotification(p->eventID, p->channelID, p->timerMod);
- else if (p->type == 2)
- AddRemoveTimerNotification(p->formatted, p->channelID, p->start);
- else if (p->type == 3)
- AddAnnounceEventNotification(p->eventID, p->channelID, p->searchID);
- p = PendingNotifications.Next(p);
+ while (p) {
+ if (p->type == 0)
+ AddNewTimerNotification(p->eventID, p->channelID);
+ else if (p->type == 1)
+ AddModTimerNotification(p->eventID, p->channelID, p->timerMod);
+ else if (p->type == 2)
+ AddRemoveTimerNotification(p->formatted, p->channelID, p->start);
+ else if (p->type == 3)
+ AddAnnounceEventNotification(p->eventID, p->channelID, p->searchID);
+ p = PendingNotifications.Next(p);
}
if (newTimers.empty() &&
- modTimers.empty() &&
- delTimers.empty() &&
- announceEvents.empty())
- return;
+ modTimers.empty() &&
+ delTimers.empty() &&
+ announceEvents.empty())
+ return;
// extract single templates
- if (mailTemplate == "")
- {
- LogFile.eSysLog("error loading %s", *AddDirectory(CONFIGDIR, "epgsearchupdmail.templ"));
- return;
+ if (mailTemplate == "") {
+ LogFile.eSysLog("error loading %s", *AddDirectory(CONFIGDIR, "epgsearchupdmail.templ"));
+ return;
}
string templSubject = GetTemplValue(mailTemplate, "subject");
string templBody = GetTemplValue(mailTemplate, "mailbody");
@@ -396,45 +385,41 @@ void cMailUpdateNotifier::SendUpdateNotifications()
// create the timer list for new timers
string newtimers;
if (newTimers.empty())
- newtimers = tr("No new timers were added.");
+ newtimers = tr("No new timers were added.");
std::set<cMailTimerNotification>::iterator itnt;
- for (itnt = newTimers.begin(); itnt != newTimers.end(); ++itnt)
- {
- string message = (*itnt).Format(templTimer);
- if (message != "") newtimers += message;
+ for (itnt = newTimers.begin(); itnt != newTimers.end(); ++itnt) {
+ string message = (*itnt).Format(templTimer);
+ if (message != "") newtimers += message;
}
// create the timer list for modified timers
string modtimers;
if (modTimers.empty())
- modtimers = tr("No timers were modified.");
+ modtimers = tr("No timers were modified.");
std::set<cMailTimerNotification>::iterator itmt;
- for (itmt = modTimers.begin(); itmt != modTimers.end(); ++itmt)
- {
- string message = (*itmt).Format(templTimer);
- if (message != "") modtimers += message;
+ for (itmt = modTimers.begin(); itmt != modTimers.end(); ++itmt) {
+ string message = (*itmt).Format(templTimer);
+ if (message != "") modtimers += message;
}
// create the timer list for removed timers
string deltimers;
if (delTimers.empty())
- deltimers = tr("No timers were deleted.");
+ deltimers = tr("No timers were deleted.");
std::set<cMailDelTimerNotification>::iterator itdt;
- for (itdt = delTimers.begin(); itdt != delTimers.end(); ++itdt)
- {
- string message = (*itdt).Format("");
- if (message != "") deltimers += message;
+ for (itdt = delTimers.begin(); itdt != delTimers.end(); ++itdt) {
+ string message = (*itdt).Format("");
+ if (message != "") deltimers += message;
}
// create the list of events to announce
string announceevents;
if (announceEvents.empty())
- announceevents = tr("No new events to announce.");
+ announceevents = tr("No new events to announce.");
std::set<cMailAnnounceEventNotification>::iterator itae;
- for (itae = announceEvents.begin(); itae != announceEvents.end(); ++itae)
- {
- string message = (*itae).Format(templEvent);
- if (message != "") announceevents += message;
+ for (itae = announceEvents.begin(); itae != announceEvents.end(); ++itae) {
+ string message = (*itae).Format(templEvent);
+ if (message != "") announceevents += message;
}
// evaluate variables
@@ -461,26 +446,23 @@ void cMailUpdateNotifier::SendUpdateNotifications()
body = ReplaceAll(body, "%update.deltimers%", deltimers);
body = ReplaceAll(body, "%update.newevents%", announceevents);
- if (SendMail())
- {
- EPGSearchConfig.lastMailOnSearchtimerAt = time(NULL);
- cPluginManager::GetPlugin("epgsearch")->SetupStore("MailNotificationSearchtimersLastAt",
- EPGSearchConfig.lastMailOnSearchtimerAt);
- // remove pending notifications
- while((p = PendingNotifications.First()) != NULL)
- PendingNotifications.Del(p);
- }
- else
- {
- // add current notifications to pending ones
- for (itnt = newTimers.begin(); itnt != newTimers.end(); ++itnt)
- PendingNotifications.Add(new cPendingNotification(0, itnt->eventID, itnt->channelID, -1));
- for (itmt = modTimers.begin(); itmt != modTimers.end(); ++itmt)
- PendingNotifications.Add(new cPendingNotification(1, itmt->eventID, itmt->channelID, -1, itmt->timerMod));
- for (itdt = delTimers.begin(); itdt != delTimers.end(); ++itdt)
- PendingNotifications.Add(new cPendingNotification(2, -1, itdt->channelID, itdt->start, -1, -1, itdt->formatted));
- for (itae = announceEvents.begin(); itae != announceEvents.end(); ++itae)
- PendingNotifications.Add(new cPendingNotification(3, itae->eventID, itae->channelID, -1, -1, itae->searchextID));
+ if (SendMail()) {
+ EPGSearchConfig.lastMailOnSearchtimerAt = time(NULL);
+ cPluginManager::GetPlugin("epgsearch")->SetupStore("MailNotificationSearchtimersLastAt",
+ EPGSearchConfig.lastMailOnSearchtimerAt);
+ // remove pending notifications
+ while ((p = PendingNotifications.First()) != NULL)
+ PendingNotifications.Del(p);
+ } else {
+ // add current notifications to pending ones
+ for (itnt = newTimers.begin(); itnt != newTimers.end(); ++itnt)
+ PendingNotifications.Add(new cPendingNotification(0, itnt->eventID, itnt->channelID, -1));
+ for (itmt = modTimers.begin(); itmt != modTimers.end(); ++itmt)
+ PendingNotifications.Add(new cPendingNotification(1, itmt->eventID, itmt->channelID, -1, itmt->timerMod));
+ for (itdt = delTimers.begin(); itdt != delTimers.end(); ++itdt)
+ PendingNotifications.Add(new cPendingNotification(2, -1, itdt->channelID, itdt->start, -1, -1, itdt->formatted));
+ for (itae = announceEvents.begin(); itae != announceEvents.end(); ++itae)
+ PendingNotifications.Add(new cPendingNotification(3, itae->eventID, itae->channelID, -1, -1, itae->searchextID));
}
PendingNotifications.Save();
@@ -488,16 +470,14 @@ void cMailUpdateNotifier::SendUpdateNotifications()
modTimers.clear();
delTimers.clear();
// Add announced events to the "no announce" list
- for (itae = announceEvents.begin(); itae != announceEvents.end(); ++itae)
- {
- cNoAnnounce* noAnnounce = new cNoAnnounce(itae->GetEvent());
- if (noAnnounce && noAnnounce->Valid())
- NoAnnounces.Add(noAnnounce);
+ for (itae = announceEvents.begin(); itae != announceEvents.end(); ++itae) {
+ cNoAnnounce* noAnnounce = new cNoAnnounce(itae->GetEvent());
+ if (noAnnounce && noAnnounce->Valid())
+ NoAnnounces.Add(noAnnounce);
}
- if (!announceEvents.empty())
- {
- NoAnnounces.ClearOutdated();
- NoAnnounces.Save();
+ if (!announceEvents.empty()) {
+ NoAnnounces.ClearOutdated();
+ NoAnnounces.Save();
}
announceEvents.clear();
@@ -508,40 +488,36 @@ void cMailUpdateNotifier::SendUpdateNotifications()
void cMailConflictNotifier::SendConflictNotifications(cConflictCheck& conflictCheck)
{
if (conflictCheck.relevantConflicts == 0)
- return;
+ return;
// check if anything has changed since last mail
ostringstream newMailConflicts;
cList<cConflictCheckTime>* failedList = conflictCheck.GetFailed();
if (!failedList) return;
- for(cConflictCheckTime* ct = failedList->First(); ct; ct = failedList->Next(ct))
- {
- if (!ct || ct->ignore) continue;
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it;
- for (it = ct->failedTimers.begin(); it != ct->failedTimers.end(); ++it)
- if ((*it) && !(*it)->ignore && (*it)->Event())
- {
- std::string channelID = *(*it)->Event()->ChannelID().ToString();
- newMailConflicts << (*it)->Event()->EventID()
- << "|"
- << channelID;
- }
+ for (cConflictCheckTime* ct = failedList->First(); ct; ct = failedList->Next(ct)) {
+ if (!ct || ct->ignore) continue;
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it;
+ for (it = ct->failedTimers.begin(); it != ct->failedTimers.end(); ++it)
+ if ((*it) && !(*it)->ignore && (*it)->Event()) {
+ std::string channelID = *(*it)->Event()->ChannelID().ToString();
+ newMailConflicts << (*it)->Event()->EventID()
+ << "|"
+ << channelID;
+ }
}
string newMailConflictsMD5 = MD5(newMailConflicts.str());
- if (newMailConflictsMD5 == EPGSearchConfig.LastMailConflicts)
- {
- LogFile.Log(3, "conflicts unchanged - no new notification needed.");
- return;
+ if (newMailConflictsMD5 == EPGSearchConfig.LastMailConflicts) {
+ LogFile.Log(3, "conflicts unchanged - no new notification needed.");
+ return;
}
// open the template
string templ = LoadTemplate("epgsearchconflmail.templ");
- if (templ == "")
- {
- LogFile.eSysLog("error loading %s", *AddDirectory(CONFIGDIR, "epgsearchconflmail.templ"));
- return;
+ if (templ == "") {
+ LogFile.eSysLog("error loading %s", *AddDirectory(CONFIGDIR, "epgsearchconflmail.templ"));
+ return;
}
// extract single templates
@@ -554,30 +530,27 @@ void cMailConflictNotifier::SendConflictNotifications(cConflictCheck& conflictCh
// create the conflict list
string conflicts;
- for(cConflictCheckTime* ct = failedList->First(); ct; ct = failedList->Next(ct))
- {
- if (ct->ignore) continue;
- // format conflict time
- string conflictsAt = templConflictsAt;
- conflictsAt = ReplaceAll(conflictsAt, "%conflict.time%", TIMESTRING(ct->evaltime));
- conflictsAt = ReplaceAll(conflictsAt, "%conflict.date%", DATESTRING(ct->evaltime));
-
- string conflicttimers;
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it;
- for (it = ct->failedTimers.begin(); it != ct->failedTimers.end(); ++it)
- if (!(*it)->ignore && (*it)->Event())
- {
- cMailTimerNotification M((*it)->Event()->EventID(), (*it)->Event()->ChannelID());
- string message = M.Format(templConflictTimer);
- if (message != "")
- {
- message = ReplaceAll(message, "%device%", NumToString((*it)->device));
- conflicttimers += message;
- }
- }
- conflictsAt = ReplaceAll(conflictsAt, "%conflict.confltimers%", conflicttimers);
-
- conflicts += conflictsAt;
+ for (cConflictCheckTime* ct = failedList->First(); ct; ct = failedList->Next(ct)) {
+ if (ct->ignore) continue;
+ // format conflict time
+ string conflictsAt = templConflictsAt;
+ conflictsAt = ReplaceAll(conflictsAt, "%conflict.time%", TIMESTRING(ct->evaltime));
+ conflictsAt = ReplaceAll(conflictsAt, "%conflict.date%", DATESTRING(ct->evaltime));
+
+ string conflicttimers;
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it;
+ for (it = ct->failedTimers.begin(); it != ct->failedTimers.end(); ++it)
+ if (!(*it)->ignore && (*it)->Event()) {
+ cMailTimerNotification M((*it)->Event()->EventID(), (*it)->Event()->ChannelID());
+ string message = M.Format(templConflictTimer);
+ if (message != "") {
+ message = ReplaceAll(message, "%device%", NumToString((*it)->device));
+ conflicttimers += message;
+ }
+ }
+ conflictsAt = ReplaceAll(conflictsAt, "%conflict.confltimers%", conflicttimers);
+
+ conflicts += conflictsAt;
}
// evaluate variables
diff --git a/mail.h b/mail.h
index b2f0894..3a3ecca 100644
--- a/mail.h
+++ b/mail.h
@@ -37,15 +37,15 @@ using std::set;
// --- cMailNotifier --------------------------------------------------------
class cMailNotifier
{
- protected:
+protected:
string subject;
string body;
bool SendMailViaSendmail();
bool SendMailViaScript();
- bool SendMail(bool force=false);
+ bool SendMail(bool force = false);
bool ExecuteMailScript(string ScriptArgs);
- public:
+public:
string scriptReply;
cMailNotifier() {}
@@ -59,42 +59,44 @@ class cMailNotifier
class cMailTimerNotification
{
- friend class cMailUpdateNotifier;
+ friend class cMailUpdateNotifier;
tEventID eventID;
tChannelID channelID;
uint timerMod;
- protected:
+protected:
virtual const cEvent* GetEvent() const;
- public:
- cMailTimerNotification(tEventID EventID, tChannelID ChannelID, uint TimerMod = tmNoChange)
- : eventID(EventID), channelID(ChannelID), timerMod(TimerMod) {}
+public:
+ cMailTimerNotification(tEventID EventID, tChannelID ChannelID, uint TimerMod = tmNoChange)
+ : eventID(EventID), channelID(ChannelID), timerMod(TimerMod) {}
virtual bool operator< (const cMailTimerNotification &N) const;
virtual string Format(const string& templ) const;
};
class cMailDelTimerNotification
{
- friend class cMailUpdateNotifier;
+ friend class cMailUpdateNotifier;
time_t start;
tChannelID channelID;
- public:
+public:
string formatted;
cMailDelTimerNotification(const cTimer* t, const cEvent* pEvent, const string& templ);
cMailDelTimerNotification(const string& Formatted, tChannelID ChannelID, time_t Start);
bool operator< (const cMailDelTimerNotification &N) const;
- string Format(const string& templ) const { return formatted; }
+ string Format(const string& templ) const {
+ return formatted;
+ }
};
class cMailAnnounceEventNotification : public cMailTimerNotification
{
- friend class cMailUpdateNotifier;
- int searchextID;
- public:
- cMailAnnounceEventNotification(tEventID EventID, tChannelID ChannelID, int SearchExtID)
- : cMailTimerNotification(EventID, ChannelID), searchextID(SearchExtID) {}
+ friend class cMailUpdateNotifier;
+ int searchextID;
+public:
+ cMailAnnounceEventNotification(tEventID EventID, tChannelID ChannelID, int SearchExtID)
+ : cMailTimerNotification(EventID, ChannelID), searchextID(SearchExtID) {}
string Format(const string& templ) const;
};
@@ -106,7 +108,7 @@ class cMailUpdateNotifier : public cMailNotifier
set<cMailAnnounceEventNotification> announceEvents;
string mailTemplate;
- public:
+public:
cMailUpdateNotifier();
void AddNewTimerNotification(tEventID EventID, tChannelID ChannelID);
void AddModTimerNotification(tEventID EventID, tChannelID ChannelID, uint timerMod = tmNoChange);
@@ -118,7 +120,7 @@ class cMailUpdateNotifier : public cMailNotifier
class cMailConflictNotifier : public cMailNotifier
{
- public:
+public:
void SendConflictNotifications(cConflictCheck& conflictcheck);
};
diff --git a/main.c b/main.c
index 00d3122..9b24e1c 100644
--- a/main.c
+++ b/main.c
@@ -35,19 +35,19 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
// A function adding two integers and returning the result
int SampleAddInt(int i1, int i2)
{
- return i1 + i2;
+ return i1 + i2;
}
// A function doing nothing ;)
void SampleFunction1()
{
- // insert code here
+ // insert code here
}
// A function always returning zero
int SampleFunction2()
{
- // insert code here
+ // insert code here
- return 0;
+ return 0;
}
diff --git a/mainmenushortcut.c b/mainmenushortcut.c
index d89d878..892284a 100644
--- a/mainmenushortcut.c
+++ b/mainmenushortcut.c
@@ -33,21 +33,21 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
static const char SETUPENTRY[] = "MainMenuEntryEnabled";
cMainMenuShortcutSetupPage::cMainMenuShortcutSetupPage(const char *setupText,
- const char *setupEntry,
- int *const setupValue)
-:_setupEntry(setupEntry), _setupValue(setupValue)
+ const char *setupEntry,
+ int *const setupValue)
+ : _setupEntry(setupEntry), _setupValue(setupValue)
{
- dummy=0;
- Add(new cMenuEditBoolItem(setupText, _setupValue, trVDR("no"), trVDR("yes")));
+ dummy = 0;
+ Add(new cMenuEditBoolItem(setupText, _setupValue, trVDR("no"), trVDR("yes")));
}
void cMainMenuShortcutSetupPage::Store()
{
- SetupStore(_setupEntry, *_setupValue);
+ SetupStore(_setupEntry, *_setupValue);
}
cMainMenuShortcut::cMainMenuShortcut()
-: _mainMenuEntryEnabled(1)
+ : _mainMenuEntryEnabled(1)
{
}
@@ -57,47 +57,47 @@ cMainMenuShortcut::~cMainMenuShortcut()
cOsdMenu *cMainMenuShortcut::GetEpgSearchMenu(const char *serviceName)
{
- cOsdMenu *menu = NULL;
- cPlugin *epgSearchPlugin = cPluginManager::GetPlugin("epgsearch");
- if (epgSearchPlugin) {
- EpgSearchMenu_v1_0 *serviceData = new EpgSearchMenu_v1_0;
-
- if (epgSearchPlugin->Service(serviceName, serviceData)) {
- menu = serviceData->Menu;
+ cOsdMenu *menu = NULL;
+ cPlugin *epgSearchPlugin = cPluginManager::GetPlugin("epgsearch");
+ if (epgSearchPlugin) {
+ EpgSearchMenu_v1_0 *serviceData = new EpgSearchMenu_v1_0;
+
+ if (epgSearchPlugin->Service(serviceName, serviceData)) {
+ menu = serviceData->Menu;
+ } else {
+ ERROR(tr("This version of EPGSearch does not support this service!"));
+ }
+
+ delete serviceData;
} else {
- ERROR(tr("This version of EPGSearch does not support this service!"));
+ ERROR(tr("EPGSearch does not exist!"));
}
-
- delete serviceData;
- } else {
- ERROR(tr("EPGSearch does not exist!"));
- }
- return menu;
+ return menu;
}
bool cMainMenuShortcut::Initialize()
{
- return true;
+ return true;
}
bool cMainMenuShortcut::SetupParse(const char *Name, const char *Value)
{
- if (!strcasecmp(Name, SETUPENTRY)) {
- _mainMenuEntryEnabled = atoi(Value);
- }
- return true;
+ if (!strcasecmp(Name, SETUPENTRY)) {
+ _mainMenuEntryEnabled = atoi(Value);
+ }
+ return true;
}
cMenuSetupPage *cMainMenuShortcut::SetupMenu()
{
- return new cMainMenuShortcutSetupPage(SetupText(), SETUPENTRY, &_mainMenuEntryEnabled);
+ return new cMainMenuShortcutSetupPage(SetupText(), SETUPENTRY, &_mainMenuEntryEnabled);
}
const char *cMainMenuShortcut::MainMenuEntry()
{
- if (_mainMenuEntryEnabled) {
- return (const char *) MainMenuText();
- } else {
- return NULL;
- }
+ if (_mainMenuEntryEnabled) {
+ return (const char *) MainMenuText();
+ } else {
+ return NULL;
+ }
}
diff --git a/mainmenushortcut.h b/mainmenushortcut.h
index 9ae9830..6867418 100644
--- a/mainmenushortcut.h
+++ b/mainmenushortcut.h
@@ -30,35 +30,35 @@ static const char I18nEpgsearch[] = "vdr-epgsearch";
class cMainMenuShortcutSetupPage : public cMenuSetupPage
{
- private:
- const char* _setupEntry;
- int* const _setupValue;
- int dummy; // don't know why, but this is necessary to avoid a crash with ext-patch and active USE_LIEMIKUUTIO
+private:
+ const char* _setupEntry;
+ int* const _setupValue;
+ int dummy; // don't know why, but this is necessary to avoid a crash with ext-patch and active USE_LIEMIKUUTIO
- public:
- cMainMenuShortcutSetupPage(const char* setupText, const char* setupEntry, int* const setupValue);
+public:
+ cMainMenuShortcutSetupPage(const char* setupText, const char* setupEntry, int* const setupValue);
- protected:
- virtual void Store(void);
+protected:
+ virtual void Store(void);
};
class cMainMenuShortcut : public cPlugin
{
- private:
- int _mainMenuEntryEnabled;
+private:
+ int _mainMenuEntryEnabled;
- public:
- cMainMenuShortcut();
- virtual ~cMainMenuShortcut();
- virtual bool Initialize();
- virtual bool SetupParse(const char* Name, const char* Value);
- virtual cMenuSetupPage* SetupMenu();
- virtual const char* MainMenuEntry();
+public:
+ cMainMenuShortcut();
+ virtual ~cMainMenuShortcut();
+ virtual bool Initialize();
+ virtual bool SetupParse(const char* Name, const char* Value);
+ virtual cMenuSetupPage* SetupMenu();
+ virtual const char* MainMenuEntry();
- protected:
- cOsdMenu* GetEpgSearchMenu(const char* serviceName);
- virtual const char* SetupText() = 0;
- virtual const char* MainMenuText() = 0;
+protected:
+ cOsdMenu* GetEpgSearchMenu(const char* serviceName);
+ virtual const char* SetupText() = 0;
+ virtual const char* MainMenuText() = 0;
};
#endif
diff --git a/md5.c b/md5.c
index bfb0730..1557ff4 100644
--- a/md5.c
+++ b/md5.c
@@ -63,11 +63,10 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "md5.h"
-static unsigned char PADDING[64] =
-{
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+static unsigned char PADDING[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
#define S11 7
@@ -91,33 +90,32 @@ static unsigned char PADDING[64] =
// PrintMD5: Converts a completed md5 digest into a char* string.
char* PrintMD5(uchar md5Digest[16])
{
- char chBuffer[256];
- char chEach[10];
- int nCount;
+ char chBuffer[256];
+ char chEach[10];
+ int nCount;
- memset(chBuffer,0,256);
- memset(chEach, 0, 10);
+ memset(chBuffer, 0, 256);
+ memset(chEach, 0, 10);
- for (nCount = 0; nCount < 16; nCount++)
- {
- sprintf(chEach, "%02x", md5Digest[nCount]);
- strncat(chBuffer, chEach, sizeof(chEach));
- }
+ for (nCount = 0; nCount < 16; nCount++) {
+ sprintf(chEach, "%02x", md5Digest[nCount]);
+ strncat(chBuffer, chEach, sizeof(chEach));
+ }
- return strdup(chBuffer);
+ return strdup(chBuffer);
}
// MD5String: Performs the MD5 algorithm on a char* string, returning
// the results as a char*.
char* MD5String(char* szString)
{
- int nLen = strlen(szString);
- md5 alg;
+ int nLen = strlen(szString);
+ md5 alg;
- alg.Update((unsigned char*)szString, (unsigned int)nLen);
- alg.Finalize();
+ alg.Update((unsigned char*)szString, (unsigned int)nLen);
+ alg.Finalize();
- return PrintMD5(alg.Digest());
+ return PrintMD5(alg.Digest());
}
@@ -125,12 +123,12 @@ char* MD5String(char* szString)
// Initializes a new context.
void md5::Init()
{
- memset(m_Count, 0, 2 * sizeof(uint4));
+ memset(m_Count, 0, 2 * sizeof(uint4));
- m_State[0] = 0x67452301;
- m_State[1] = 0xefcdab89;
- m_State[2] = 0x98badcfe;
- m_State[3] = 0x10325476;
+ m_State[0] = 0x67452301;
+ m_State[1] = 0xefcdab89;
+ m_State[2] = 0x98badcfe;
+ m_State[3] = 0x10325476;
}
// md5::Update
@@ -139,35 +137,33 @@ void md5::Init()
// context.
void md5::Update(uchar* chInput, uint4 nInputLen)
{
- uint4 i, index, partLen;
+ uint4 i, index, partLen;
- // Compute number of bytes mod 64
- index = (unsigned int)((m_Count[0] >> 3) & 0x3F);
+ // Compute number of bytes mod 64
+ index = (unsigned int)((m_Count[0] >> 3) & 0x3F);
- // Update number of bits
- if ((m_Count[0] += (nInputLen << 3)) < (nInputLen << 3))
- m_Count[1]++;
+ // Update number of bits
+ if ((m_Count[0] += (nInputLen << 3)) < (nInputLen << 3))
+ m_Count[1]++;
- m_Count[1] += (nInputLen >> 29);
+ m_Count[1] += (nInputLen >> 29);
- partLen = 64 - index;
+ partLen = 64 - index;
- // Transform as many times as possible.
- if (nInputLen >= partLen)
- {
- memcpy( &m_Buffer[index], chInput, partLen );
- Transform(m_Buffer);
+ // Transform as many times as possible.
+ if (nInputLen >= partLen) {
+ memcpy(&m_Buffer[index], chInput, partLen);
+ Transform(m_Buffer);
- for (i = partLen; i + 63 < nInputLen; i += 64)
- Transform(&chInput[i]);
+ for (i = partLen; i + 63 < nInputLen; i += 64)
+ Transform(&chInput[i]);
- index = 0;
- }
- else
- i = 0;
+ index = 0;
+ } else
+ i = 0;
- // Buffer remaining input
- memcpy( &m_Buffer[index], &chInput[i], nInputLen-i );
+ // Buffer remaining input
+ memcpy(&m_Buffer[index], &chInput[i], nInputLen - i);
}
// md5::Finalize
@@ -175,114 +171,114 @@ void md5::Update(uchar* chInput, uint4 nInputLen)
// the message digest and zeroizing the context.
void md5::Finalize()
{
- uchar bits[8];
- uint4 index, padLen;
+ uchar bits[8];
+ uint4 index, padLen;
- // Save number of bits
- Encode (bits, m_Count, 8);
+ // Save number of bits
+ Encode(bits, m_Count, 8);
- // Pad out to 56 mod 64
- index = (unsigned int)((m_Count[0] >> 3) & 0x3f);
- padLen = (index < 56) ? (56 - index) : (120 - index);
- Update(PADDING, padLen);
+ // Pad out to 56 mod 64
+ index = (unsigned int)((m_Count[0] >> 3) & 0x3f);
+ padLen = (index < 56) ? (56 - index) : (120 - index);
+ Update(PADDING, padLen);
- // Append length (before padding)
- Update (bits, 8);
+ // Append length (before padding)
+ Update(bits, 8);
- // Store state in digest
- Encode (m_Digest, m_State, 16);
+ // Store state in digest
+ Encode(m_Digest, m_State, 16);
- memset(m_Count, 0, 2 * sizeof(uint4));
- memset(m_State, 0, 4 * sizeof(uint4));
- memset(m_Buffer,0, 64 * sizeof(uchar));
+ memset(m_Count, 0, 2 * sizeof(uint4));
+ memset(m_State, 0, 4 * sizeof(uint4));
+ memset(m_Buffer, 0, 64 * sizeof(uchar));
}
// md5::Transform
// MD5 basic transformation. Transforms state based on block.
-void md5::Transform (uchar* block)
+void md5::Transform(uchar* block)
{
- uint4 a = m_State[0], b = m_State[1], c = m_State[2], d = m_State[3], x[16];
-
- Decode (x, block, 64);
-
- // Round 1
- FF (a, b, c, d, x[ 0], S11, 0xd76aa478);
- FF (d, a, b, c, x[ 1], S12, 0xe8c7b756);
- FF (c, d, a, b, x[ 2], S13, 0x242070db);
- FF (b, c, d, a, x[ 3], S14, 0xc1bdceee);
- FF (a, b, c, d, x[ 4], S11, 0xf57c0faf);
- FF (d, a, b, c, x[ 5], S12, 0x4787c62a);
- FF (c, d, a, b, x[ 6], S13, 0xa8304613);
- FF (b, c, d, a, x[ 7], S14, 0xfd469501);
- FF (a, b, c, d, x[ 8], S11, 0x698098d8);
- FF (d, a, b, c, x[ 9], S12, 0x8b44f7af);
- FF (c, d, a, b, x[10], S13, 0xffff5bb1);
- FF (b, c, d, a, x[11], S14, 0x895cd7be);
- FF (a, b, c, d, x[12], S11, 0x6b901122);
- FF (d, a, b, c, x[13], S12, 0xfd987193);
- FF (c, d, a, b, x[14], S13, 0xa679438e);
- FF (b, c, d, a, x[15], S14, 0x49b40821);
-
- // Round 2
- GG (a, b, c, d, x[ 1], S21, 0xf61e2562);
- GG (d, a, b, c, x[ 6], S22, 0xc040b340);
- GG (c, d, a, b, x[11], S23, 0x265e5a51);
- GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa);
- GG (a, b, c, d, x[ 5], S21, 0xd62f105d);
- GG (d, a, b, c, x[10], S22, 0x2441453);
- GG (c, d, a, b, x[15], S23, 0xd8a1e681);
- GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8);
- GG (a, b, c, d, x[ 9], S21, 0x21e1cde6);
- GG (d, a, b, c, x[14], S22, 0xc33707d6);
- GG (c, d, a, b, x[ 3], S23, 0xf4d50d87);
- GG (b, c, d, a, x[ 8], S24, 0x455a14ed);
- GG (a, b, c, d, x[13], S21, 0xa9e3e905);
- GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8);
- GG (c, d, a, b, x[ 7], S23, 0x676f02d9);
- GG (b, c, d, a, x[12], S24, 0x8d2a4c8a);
-
- // Round 3
- HH (a, b, c, d, x[ 5], S31, 0xfffa3942);
- HH (d, a, b, c, x[ 8], S32, 0x8771f681);
- HH (c, d, a, b, x[11], S33, 0x6d9d6122);
- HH (b, c, d, a, x[14], S34, 0xfde5380c);
- HH (a, b, c, d, x[ 1], S31, 0xa4beea44);
- HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9);
- HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60);
- HH (b, c, d, a, x[10], S34, 0xbebfbc70);
- HH (a, b, c, d, x[13], S31, 0x289b7ec6);
- HH (d, a, b, c, x[ 0], S32, 0xeaa127fa);
- HH (c, d, a, b, x[ 3], S33, 0xd4ef3085);
- HH (b, c, d, a, x[ 6], S34, 0x4881d05);
- HH (a, b, c, d, x[ 9], S31, 0xd9d4d039);
- HH (d, a, b, c, x[12], S32, 0xe6db99e5);
- HH (c, d, a, b, x[15], S33, 0x1fa27cf8);
- HH (b, c, d, a, x[ 2], S34, 0xc4ac5665);
-
- // Round 4
- II (a, b, c, d, x[ 0], S41, 0xf4292244);
- II (d, a, b, c, x[ 7], S42, 0x432aff97);
- II (c, d, a, b, x[14], S43, 0xab9423a7);
- II (b, c, d, a, x[ 5], S44, 0xfc93a039);
- II (a, b, c, d, x[12], S41, 0x655b59c3);
- II (d, a, b, c, x[ 3], S42, 0x8f0ccc92);
- II (c, d, a, b, x[10], S43, 0xffeff47d);
- II (b, c, d, a, x[ 1], S44, 0x85845dd1);
- II (a, b, c, d, x[ 8], S41, 0x6fa87e4f);
- II (d, a, b, c, x[15], S42, 0xfe2ce6e0);
- II (c, d, a, b, x[ 6], S43, 0xa3014314);
- II (b, c, d, a, x[13], S44, 0x4e0811a1);
- II (a, b, c, d, x[ 4], S41, 0xf7537e82);
- II (d, a, b, c, x[11], S42, 0xbd3af235);
- II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb);
- II (b, c, d, a, x[ 9], S44, 0xeb86d391);
-
- m_State[0] += a;
- m_State[1] += b;
- m_State[2] += c;
- m_State[3] += d;
-
- memset(x, 0, sizeof(x));
+ uint4 a = m_State[0], b = m_State[1], c = m_State[2], d = m_State[3], x[16];
+
+ Decode(x, block, 64);
+
+ // Round 1
+ FF(a, b, c, d, x[ 0], S11, 0xd76aa478);
+ FF(d, a, b, c, x[ 1], S12, 0xe8c7b756);
+ FF(c, d, a, b, x[ 2], S13, 0x242070db);
+ FF(b, c, d, a, x[ 3], S14, 0xc1bdceee);
+ FF(a, b, c, d, x[ 4], S11, 0xf57c0faf);
+ FF(d, a, b, c, x[ 5], S12, 0x4787c62a);
+ FF(c, d, a, b, x[ 6], S13, 0xa8304613);
+ FF(b, c, d, a, x[ 7], S14, 0xfd469501);
+ FF(a, b, c, d, x[ 8], S11, 0x698098d8);
+ FF(d, a, b, c, x[ 9], S12, 0x8b44f7af);
+ FF(c, d, a, b, x[10], S13, 0xffff5bb1);
+ FF(b, c, d, a, x[11], S14, 0x895cd7be);
+ FF(a, b, c, d, x[12], S11, 0x6b901122);
+ FF(d, a, b, c, x[13], S12, 0xfd987193);
+ FF(c, d, a, b, x[14], S13, 0xa679438e);
+ FF(b, c, d, a, x[15], S14, 0x49b40821);
+
+// Round 2
+ GG(a, b, c, d, x[ 1], S21, 0xf61e2562);
+ GG(d, a, b, c, x[ 6], S22, 0xc040b340);
+ GG(c, d, a, b, x[11], S23, 0x265e5a51);
+ GG(b, c, d, a, x[ 0], S24, 0xe9b6c7aa);
+ GG(a, b, c, d, x[ 5], S21, 0xd62f105d);
+ GG(d, a, b, c, x[10], S22, 0x2441453);
+ GG(c, d, a, b, x[15], S23, 0xd8a1e681);
+ GG(b, c, d, a, x[ 4], S24, 0xe7d3fbc8);
+ GG(a, b, c, d, x[ 9], S21, 0x21e1cde6);
+ GG(d, a, b, c, x[14], S22, 0xc33707d6);
+ GG(c, d, a, b, x[ 3], S23, 0xf4d50d87);
+ GG(b, c, d, a, x[ 8], S24, 0x455a14ed);
+ GG(a, b, c, d, x[13], S21, 0xa9e3e905);
+ GG(d, a, b, c, x[ 2], S22, 0xfcefa3f8);
+ GG(c, d, a, b, x[ 7], S23, 0x676f02d9);
+ GG(b, c, d, a, x[12], S24, 0x8d2a4c8a);
+
+ // Round 3
+ HH(a, b, c, d, x[ 5], S31, 0xfffa3942);
+ HH(d, a, b, c, x[ 8], S32, 0x8771f681);
+ HH(c, d, a, b, x[11], S33, 0x6d9d6122);
+ HH(b, c, d, a, x[14], S34, 0xfde5380c);
+ HH(a, b, c, d, x[ 1], S31, 0xa4beea44);
+ HH(d, a, b, c, x[ 4], S32, 0x4bdecfa9);
+ HH(c, d, a, b, x[ 7], S33, 0xf6bb4b60);
+ HH(b, c, d, a, x[10], S34, 0xbebfbc70);
+ HH(a, b, c, d, x[13], S31, 0x289b7ec6);
+ HH(d, a, b, c, x[ 0], S32, 0xeaa127fa);
+ HH(c, d, a, b, x[ 3], S33, 0xd4ef3085);
+ HH(b, c, d, a, x[ 6], S34, 0x4881d05);
+ HH(a, b, c, d, x[ 9], S31, 0xd9d4d039);
+ HH(d, a, b, c, x[12], S32, 0xe6db99e5);
+ HH(c, d, a, b, x[15], S33, 0x1fa27cf8);
+ HH(b, c, d, a, x[ 2], S34, 0xc4ac5665);
+
+ // Round 4
+ II(a, b, c, d, x[ 0], S41, 0xf4292244);
+ II(d, a, b, c, x[ 7], S42, 0x432aff97);
+ II(c, d, a, b, x[14], S43, 0xab9423a7);
+ II(b, c, d, a, x[ 5], S44, 0xfc93a039);
+ II(a, b, c, d, x[12], S41, 0x655b59c3);
+ II(d, a, b, c, x[ 3], S42, 0x8f0ccc92);
+ II(c, d, a, b, x[10], S43, 0xffeff47d);
+ II(b, c, d, a, x[ 1], S44, 0x85845dd1);
+ II(a, b, c, d, x[ 8], S41, 0x6fa87e4f);
+ II(d, a, b, c, x[15], S42, 0xfe2ce6e0);
+ II(c, d, a, b, x[ 6], S43, 0xa3014314);
+ II(b, c, d, a, x[13], S44, 0x4e0811a1);
+ II(a, b, c, d, x[ 4], S41, 0xf7537e82);
+ II(d, a, b, c, x[11], S42, 0xbd3af235);
+ II(c, d, a, b, x[ 2], S43, 0x2ad7d2bb);
+ II(b, c, d, a, x[ 9], S44, 0xeb86d391);
+
+ m_State[0] += a;
+ m_State[1] += b;
+ m_State[2] += c;
+ m_State[3] += d;
+
+ memset(x, 0, sizeof(x));
}
// md5::Encode
@@ -290,17 +286,16 @@ void md5::Transform (uchar* block)
// a multiple of 4.
void md5::Encode(uchar* dest, uint4* src, uint4 nLength)
{
- uint4 i, j;
+ uint4 i, j;
- assert(nLength % 4 == 0);
+ assert(nLength % 4 == 0);
- for (i = 0, j = 0; j < nLength; i++, j += 4)
- {
- dest[j] = (uchar)(src[i] & 0xff);
- dest[j+1] = (uchar)((src[i] >> 8) & 0xff);
- dest[j+2] = (uchar)((src[i] >> 16) & 0xff);
- dest[j+3] = (uchar)((src[i] >> 24) & 0xff);
- }
+ for (i = 0, j = 0; j < nLength; i++, j += 4) {
+ dest[j] = (uchar)(src[i] & 0xff);
+ dest[j + 1] = (uchar)((src[i] >> 8) & 0xff);
+ dest[j + 2] = (uchar)((src[i] >> 16) & 0xff);
+ dest[j + 3] = (uchar)((src[i] >> 24) & 0xff);
+ }
}
// md5::Decode
@@ -308,13 +303,12 @@ void md5::Encode(uchar* dest, uint4* src, uint4 nLength)
// a multiple of 4.
void md5::Decode(uint4* dest, uchar* src, uint4 nLength)
{
- uint4 i, j;
+ uint4 i, j;
- assert(nLength % 4 == 0);
+ assert(nLength % 4 == 0);
- for (i = 0, j = 0; j < nLength; i++, j += 4)
- {
- dest[i] = ((uint4)src[j]) | (((uint4)src[j+1])<<8) |
- (((uint4)src[j+2])<<16) | (((uint4)src[j+3])<<24);
- }
+ for (i = 0, j = 0; j < nLength; i++, j += 4) {
+ dest[i] = ((uint4)src[j]) | (((uint4)src[j + 1]) << 8) |
+ (((uint4)src[j + 2]) << 16) | (((uint4)src[j + 3]) << 24);
+ }
}
diff --git a/md5.h b/md5.h
index 099000a..12678f1 100644
--- a/md5.h
+++ b/md5.h
@@ -67,52 +67,76 @@ class md5
{
// Methods
public:
- md5() { Init(); m_Buffer[0]=0; m_Digest[0]=0; m_Finalized=0; }
- void Init();
- void Update(uchar* chInput, uint4 nInputLen);
- void Finalize();
- uchar* Digest() { return m_Digest; }
+ md5() {
+ Init();
+ m_Buffer[0] = 0;
+ m_Digest[0] = 0;
+ m_Finalized = 0;
+ }
+ void Init();
+ void Update(uchar* chInput, uint4 nInputLen);
+ void Finalize();
+ uchar* Digest() {
+ return m_Digest;
+ }
private:
- void Transform(uchar* block);
- void Encode(uchar* dest, uint4* src, uint4 nLength);
- void Decode(uint4* dest, uchar* src, uint4 nLength);
+ void Transform(uchar* block);
+ void Encode(uchar* dest, uint4* src, uint4 nLength);
+ void Decode(uint4* dest, uchar* src, uint4 nLength);
- inline uint4 rotate_left(uint4 x, uint4 n)
- { return ((x << n) | (x >> (32-n))); }
+ inline uint4 rotate_left(uint4 x, uint4 n) {
+ return ((x << n) | (x >> (32 - n)));
+ }
- inline uint4 F(uint4 x, uint4 y, uint4 z)
- { return ((x & y) | (~x & z)); }
+ inline uint4 F(uint4 x, uint4 y, uint4 z) {
+ return ((x & y) | (~x & z));
+ }
- inline uint4 G(uint4 x, uint4 y, uint4 z)
- { return ((x & z) | (y & ~z)); }
+ inline uint4 G(uint4 x, uint4 y, uint4 z) {
+ return ((x & z) | (y & ~z));
+ }
- inline uint4 H(uint4 x, uint4 y, uint4 z)
- { return (x ^ y ^ z); }
+ inline uint4 H(uint4 x, uint4 y, uint4 z) {
+ return (x ^ y ^ z);
+ }
- inline uint4 I(uint4 x, uint4 y, uint4 z)
- { return (y ^ (x | ~z)); }
+ inline uint4 I(uint4 x, uint4 y, uint4 z) {
+ return (y ^ (x | ~z));
+ }
- inline void FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
- { a += F(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
+ inline void FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
+ a += F(b, c, d) + x + ac;
+ a = rotate_left(a, s);
+ a += b;
+ }
- inline void GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
- { a += G(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
+ inline void GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
+ a += G(b, c, d) + x + ac;
+ a = rotate_left(a, s);
+ a += b;
+ }
- inline void HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
- { a += H(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
+ inline void HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
+ a += H(b, c, d) + x + ac;
+ a = rotate_left(a, s);
+ a += b;
+ }
- inline void II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
- { a += I(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
+ inline void II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
+ a += I(b, c, d) + x + ac;
+ a = rotate_left(a, s);
+ a += b;
+ }
// Data
private:
- uint4 m_State[4];
- uint4 m_Count[2];
- uchar m_Buffer[64];
- uchar m_Digest[16];
- uchar m_Finalized;
+ uint4 m_State[4];
+ uint4 m_Count[2];
+ uchar m_Buffer[64];
+ uchar m_Digest[16];
+ uchar m_Finalized;
};
diff --git a/menu_announcelist.c b/menu_announcelist.c
index 125fbeb..638cba0 100644
--- a/menu_announcelist.c
+++ b/menu_announcelist.c
@@ -30,175 +30,159 @@ bool cMenuAnnounceList::showsDetails;
// --- cMenuAnnounceList -------------------------------------------------------
cMenuAnnounceList::cMenuAnnounceList(cSearchResults& SearchResults)
- :cMenuSearchResultsForList(SearchResults, tr("%d new broadcast"), false)
+ : cMenuSearchResultsForList(SearchResults, tr("%d new broadcast"), false)
{
- showsDetails = false;
+ showsDetails = false;
}
void cMenuAnnounceList::SetHelpKeys(bool Force)
{
- cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
- int NewHelpKeys = 0;
- if (item) {
- if (item->Selectable() && item->timerMatch == tmFull)
- NewHelpKeys = 2;
- else
- NewHelpKeys = 1;
- }
-
- bool hasTimer = (NewHelpKeys == 2);
- if (NewHelpKeys != helpKeys || Force)
- {
- if (toggleKeys==0)
- SetHelp((EPGSearchConfig.redkeymode==0?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), m_bSort? tr("Button$by channel"):tr("Button$by time"), modeYellow==showTitleEpisode?tr("Button$Episode"):tr("Button$Title"), trVDR("Button$Edit"));
- else
- SetHelp((EPGSearchConfig.redkeymode==1?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), m_bSort? tr("Button$by channel"):tr("Button$by time"), modeYellow==showTitleEpisode?tr("Button$Episode"):tr("Button$Title"), trVDR("Button$Edit"));
- helpKeys = NewHelpKeys;
+ cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
+ int NewHelpKeys = 0;
+ if (item) {
+ if (item->Selectable() && item->timerMatch == tmFull)
+ NewHelpKeys = 2;
+ else
+ NewHelpKeys = 1;
+ }
+
+ bool hasTimer = (NewHelpKeys == 2);
+ if (NewHelpKeys != helpKeys || Force) {
+ if (toggleKeys == 0)
+ SetHelp((EPGSearchConfig.redkeymode == 0 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), m_bSort ? tr("Button$by channel") : tr("Button$by time"), modeYellow == showTitleEpisode ? tr("Button$Episode") : tr("Button$Title"), trVDR("Button$Edit"));
+ else
+ SetHelp((EPGSearchConfig.redkeymode == 1 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), m_bSort ? tr("Button$by channel") : tr("Button$by time"), modeYellow == showTitleEpisode ? tr("Button$Episode") : tr("Button$Title"), trVDR("Button$Edit"));
+ helpKeys = NewHelpKeys;
}
}
eOSState cMenuAnnounceList::ProcessKey(eKeys Key)
{
- eOSState state = cMenuSearchResultsForList::ProcessKey(Key);
- if (state == osUnknown)
- {
- switch (Key) {
- case kBlue:
- {
+ eOSState state = cMenuSearchResultsForList::ProcessKey(Key);
+ if (state == osUnknown) {
+ switch (Key) {
+ case kBlue: {
cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
- if (item)
- {
- if (!HasSubMenu())
- return AddSubMenu(new cMenuAnnounceDetails(item->event, item->search));
- else if (!showsDetails)
- return Switch();
- else
- return osContinue;
+ if (item) {
+ if (!HasSubMenu())
+ return AddSubMenu(new cMenuAnnounceDetails(item->event, item->search));
+ else if (!showsDetails)
+ return Switch();
+ else
+ return osContinue;
}
- }
- break;
- default:
+ }
+ break;
+ default:
break;
- }
- }
- return state;
+ }
+ }
+ return state;
}
// --- cMenuAnnounceDetails -------------------------------------------------------
cMenuAnnounceDetails::cMenuAnnounceDetails(const cEvent* Event, const cSearchExt* Search)
-:cOsdMenu("", 25), event(Event)
+ : cOsdMenu("", 25), event(Event)
{
- SetMenuCategory(mcEvent);
- cMenuAnnounceList::showsDetails = true;
- if (event && !isempty(event->Title()))
- {
- cString szTitle = cString::sprintf("%s: %s", tr("announce details"), event->Title());
- SetTitle(szTitle);
- }
- search = Search;
-
- announceAgain = 1;
- announceWithNextUpdate = 1;
- announceAgainDay = 0;
-
- cNoAnnounce* noAnnounce = NoAnnounces.InList(event);
- if (noAnnounce)
- {
- if (noAnnounce->nextAnnounce > 0)
- {
- announceAgainDay = noAnnounce->nextAnnounce;
- announceWithNextUpdate = 0;
- }
- else
- announceAgain = 0;
- }
- Set();
+ SetMenuCategory(mcEvent);
+ cMenuAnnounceList::showsDetails = true;
+ if (event && !isempty(event->Title())) {
+ cString szTitle = cString::sprintf("%s: %s", tr("announce details"), event->Title());
+ SetTitle(szTitle);
+ }
+ search = Search;
+
+ announceAgain = 1;
+ announceWithNextUpdate = 1;
+ announceAgainDay = 0;
+
+ cNoAnnounce* noAnnounce = NoAnnounces.InList(event);
+ if (noAnnounce) {
+ if (noAnnounce->nextAnnounce > 0) {
+ announceAgainDay = noAnnounce->nextAnnounce;
+ announceWithNextUpdate = 0;
+ } else
+ announceAgain = 0;
+ }
+ Set();
}
cMenuAnnounceDetails::~cMenuAnnounceDetails()
{
- cMenuAnnounceList::showsDetails = false;
+ cMenuAnnounceList::showsDetails = false;
}
void cMenuAnnounceDetails::Set()
{
- int current = Current();
- Clear();
-
- Add(new cMenuEditBoolItem(tr("announce again"), &announceAgain, trVDR("no"), trVDR("yes")));
- if (announceAgain)
- {
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("with next update")), &announceWithNextUpdate, trVDR("no"), trVDR("yes")));
- if (!announceWithNextUpdate)
- Add(new cMenuEditDateItem(IndentMenuItem(IndentMenuItem(tr("again from"))), &announceAgainDay, NULL));
- }
- else
- announceAgainDay = 0;
-
- if (search)
- {
- cOsdItem* pInfoItem = new cOsdItem("");
- pInfoItem->SetSelectable(false);
- Add(pInfoItem);
-
- cString info = cString::sprintf("%s: %s", tr("Search timer"), search->search);
- pInfoItem = new cOsdItem(info);
- pInfoItem->SetSelectable(false);
- Add(pInfoItem);
- }
-
- SetCurrent(Get(current));
- Display();
+ int current = Current();
+ Clear();
+
+ Add(new cMenuEditBoolItem(tr("announce again"), &announceAgain, trVDR("no"), trVDR("yes")));
+ if (announceAgain) {
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("with next update")), &announceWithNextUpdate, trVDR("no"), trVDR("yes")));
+ if (!announceWithNextUpdate)
+ Add(new cMenuEditDateItem(IndentMenuItem(IndentMenuItem(tr("again from"))), &announceAgainDay, NULL));
+ } else
+ announceAgainDay = 0;
+
+ if (search) {
+ cOsdItem* pInfoItem = new cOsdItem("");
+ pInfoItem->SetSelectable(false);
+ Add(pInfoItem);
+
+ cString info = cString::sprintf("%s: %s", tr("Search timer"), search->search);
+ pInfoItem = new cOsdItem(info);
+ pInfoItem->SetSelectable(false);
+ Add(pInfoItem);
+ }
+
+ SetCurrent(Get(current));
+ Display();
}
eOSState cMenuAnnounceDetails::ProcessKey(eKeys Key)
{
- int iTemp_announceAgain = announceAgain;
- int iTemp_announceWithNextUpdate = announceWithNextUpdate;
-
- eOSState state = cOsdMenu::ProcessKey(Key);
-
- if (iTemp_announceAgain != announceAgain ||
- iTemp_announceWithNextUpdate != announceWithNextUpdate)
- {
- Set();
- Display();
- }
-
- if (state == osUnknown) {
- switch (Key) {
- case kRed:
- case kGreen:
- case kBlue:
- case kYellow:
- case kFastRew:
- case kFastFwd:
- case kRecord:
- case k0...k9:
+ int iTemp_announceAgain = announceAgain;
+ int iTemp_announceWithNextUpdate = announceWithNextUpdate;
+
+ eOSState state = cOsdMenu::ProcessKey(Key);
+
+ if (iTemp_announceAgain != announceAgain ||
+ iTemp_announceWithNextUpdate != announceWithNextUpdate) {
+ Set();
+ Display();
+ }
+
+ if (state == osUnknown) {
+ switch (Key) {
+ case kRed:
+ case kGreen:
+ case kBlue:
+ case kYellow:
+ case kFastRew:
+ case kFastFwd:
+ case kRecord:
+ case k0...k9:
return osContinue;
- case kOk:
- {
+ case kOk: {
cNoAnnounce* noAnnounce = NoAnnounces.InList(event);
- if (!announceAgain || !announceWithNextUpdate)
- {
- if (!noAnnounce)
- {
- noAnnounce = new cNoAnnounce(event, announceAgainDay);
- NoAnnounces.Add(noAnnounce);
- }
- else
- NoAnnounces.UpdateNextAnnounce(event, announceAgainDay);
- NoAnnounces.ClearOutdated();
+ if (!announceAgain || !announceWithNextUpdate) {
+ if (!noAnnounce) {
+ noAnnounce = new cNoAnnounce(event, announceAgainDay);
+ NoAnnounces.Add(noAnnounce);
+ } else
+ NoAnnounces.UpdateNextAnnounce(event, announceAgainDay);
+ NoAnnounces.ClearOutdated();
}
if (announceAgain && announceWithNextUpdate && noAnnounce)
- NoAnnounces.Del(noAnnounce);
+ NoAnnounces.Del(noAnnounce);
NoAnnounces.Save();
- }
- return osBack;
- default:
+ }
+ return osBack;
+ default:
break;
- }
- }
+ }
+ }
- return state;
+ return state;
}
diff --git a/menu_announcelist.h b/menu_announcelist.h
index b7cb5a2..5239bdc 100644
--- a/menu_announcelist.h
+++ b/menu_announcelist.h
@@ -27,27 +27,29 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "menu_searchresults.h"
// --- cMenuAnnounceList ------------------------------------------------------
-class cMenuAnnounceList : public cMenuSearchResultsForList {
- friend class cMenuAnnounceDetails;
- virtual void SetHelpKeys(bool Force=false);
- eOSState ProcessKey(eKeys Key);
- protected:
- static bool showsDetails;
- public:
- cMenuAnnounceList(cSearchResults& SearchResults);
+class cMenuAnnounceList : public cMenuSearchResultsForList
+{
+ friend class cMenuAnnounceDetails;
+ virtual void SetHelpKeys(bool Force = false);
+ eOSState ProcessKey(eKeys Key);
+protected:
+ static bool showsDetails;
+public:
+ cMenuAnnounceList(cSearchResults& SearchResults);
};
// --- cMenuAnnounceDetails ------------------------------------------------------
-class cMenuAnnounceDetails : public cOsdMenu {
- const cEvent* event;
- const cSearchExt* search;
- int announceAgain;
- int announceWithNextUpdate;
- time_t announceAgainDay;
- eOSState ProcessKey(eKeys Key);
- void Set();
- public:
- cMenuAnnounceDetails(const cEvent* Event, const cSearchExt* Search);
- ~cMenuAnnounceDetails();
+class cMenuAnnounceDetails : public cOsdMenu
+{
+ const cEvent* event;
+ const cSearchExt* search;
+ int announceAgain;
+ int announceWithNextUpdate;
+ time_t announceAgainDay;
+ eOSState ProcessKey(eKeys Key);
+ void Set();
+public:
+ cMenuAnnounceDetails(const cEvent* Event, const cSearchExt* Search);
+ ~cMenuAnnounceDetails();
};
#endif
diff --git a/menu_blacklistedit.c b/menu_blacklistedit.c
index 4db0815..58dc78a 100644
--- a/menu_blacklistedit.c
+++ b/menu_blacklistedit.c
@@ -40,9 +40,9 @@ extern const char AllowedChars[];
// --- cMenuBlacklistEdit --------------------------------------------------------
cMenuBlacklistEdit::cMenuBlacklistEdit(cBlacklist *Blacklist, bool New)
-:cOsdMenu(tr("Edit blacklist"),32)
+ : cOsdMenu(tr("Edit blacklist"), 32)
{
- SetMenuCategory(mcSetupPlugins);
+ SetMenuCategory(mcSetupPlugins);
SearchModes[0] = strdup(tr("phrase"));
SearchModes[1] = strdup(tr("all words"));
SearchModes[2] = strdup(tr("at least one word"));
@@ -64,73 +64,62 @@ cMenuBlacklistEdit::cMenuBlacklistEdit(cBlacklist *Blacklist, bool New)
UseChannelSel[2] = strdup(tr("channel group"));
UseChannelSel[3] = strdup(tr("only FTA"));
- if (New)
- {
- cSearchExt* SearchTempl = NULL; // copy the default settings, if we have a default template
- cMutexLock SearchTemplatesLock(&SearchTemplates);
- cSearchExt *SearchExtTempl = SearchTemplates.First();
- while (SearchExtTempl)
- {
- if (SearchExtTempl->ID == EPGSearchConfig.DefSearchTemplateID)
- SearchTempl = SearchExtTempl;
- SearchExtTempl = SearchTemplates.Next(SearchExtTempl);
- }
- if (SearchTempl)
- Blacklist->CopyFromTemplate(SearchTempl);
+ if (New) {
+ cSearchExt* SearchTempl = NULL; // copy the default settings, if we have a default template
+ cMutexLock SearchTemplatesLock(&SearchTemplates);
+ cSearchExt *SearchExtTempl = SearchTemplates.First();
+ while (SearchExtTempl) {
+ if (SearchExtTempl->ID == EPGSearchConfig.DefSearchTemplateID)
+ SearchTempl = SearchExtTempl;
+ SearchExtTempl = SearchTemplates.Next(SearchExtTempl);
+ }
+ if (SearchTempl)
+ Blacklist->CopyFromTemplate(SearchTempl);
}
blacklist = Blacklist;
addIfConfirmed = New;
- if (blacklist)
- {
- data = *blacklist;
- UserDefDayOfWeek = 0;
- if (blacklist->DayOfWeek < 0)
- {
- UserDefDayOfWeek = blacklist->DayOfWeek;
- data.DayOfWeek = 7;
- }
-
- menuitemsChGr = NULL;
- channelGroupName = NULL;
-
- channelMin = channelMax = cDevice::CurrentChannel();
- channelGroupNr = 0;
- if (data.useChannel==1)
- {
- channelMin = data.channelMin->Number();
- channelMax = data.channelMax->Number();
- }
- if (data.useChannel==2)
- {
- channelGroupNr = ChannelGroups.GetIndex(data.channelGroup);
- if (channelGroupNr == -1)
- {
- free(data.channelGroup);
- data.channelGroup = NULL;
- channelGroupNr = 0; // no selection
- }
- else
- {
- channelGroupName = strdup(data.channelGroup);
- channelGroupNr++;
- }
- }
- catvaluesNumeric = NULL;
- if (SearchExtCats.Count() > 0)
- {
- catvaluesNumeric = (int*) malloc(SearchExtCats.Count() * sizeof(int));
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- catvaluesNumeric[index] = atol(blacklist->catvalues[index]);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- }
- Set();
+ if (blacklist) {
+ data = *blacklist;
+ UserDefDayOfWeek = 0;
+ if (blacklist->DayOfWeek < 0) {
+ UserDefDayOfWeek = blacklist->DayOfWeek;
+ data.DayOfWeek = 7;
+ }
+
+ menuitemsChGr = NULL;
+ channelGroupName = NULL;
+
+ channelMin = channelMax = cDevice::CurrentChannel();
+ channelGroupNr = 0;
+ if (data.useChannel == 1) {
+ channelMin = data.channelMin->Number();
+ channelMax = data.channelMax->Number();
+ }
+ if (data.useChannel == 2) {
+ channelGroupNr = ChannelGroups.GetIndex(data.channelGroup);
+ if (channelGroupNr == -1) {
+ free(data.channelGroup);
+ data.channelGroup = NULL;
+ channelGroupNr = 0; // no selection
+ } else {
+ channelGroupName = strdup(data.channelGroup);
+ channelGroupNr++;
+ }
+ }
+ catvaluesNumeric = NULL;
+ if (SearchExtCats.Count() > 0) {
+ catvaluesNumeric = (int*) malloc(SearchExtCats.Count() * sizeof(int));
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ catvaluesNumeric[index] = atol(blacklist->catvalues[index]);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+ }
+ Set();
}
}
@@ -139,84 +128,74 @@ void cMenuBlacklistEdit::Set()
int current = Current();
Clear();
- Add(new cMenuEditStrItem( tr("Search term"), data.search, sizeof(data.search), tr(AllowedChars)));
+ Add(new cMenuEditStrItem(tr("Search term"), data.search, sizeof(data.search), tr(AllowedChars)));
Add(new cMenuEditStraItem(tr("Search mode"), &data.mode, 6, SearchModes));
if (data.mode == 5) // fuzzy
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Tolerance")), &data.fuzzyTolerance, 1, 9));
- Add(new cMenuEditBoolItem( tr("Match case"), &data.useCase, trVDR("no"), trVDR("yes")));
- Add(new cMenuEditBoolItem( tr("Use title"), &data.useTitle, trVDR("no"), trVDR("yes")));
- Add(new cMenuEditBoolItem( tr("Use subtitle"), &data.useSubtitle, trVDR("no"), trVDR("yes")));
- Add(new cMenuEditBoolItem( tr("Use description"), &data.useDescription, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Tolerance")), &data.fuzzyTolerance, 1, 9));
+ Add(new cMenuEditBoolItem(tr("Match case"), &data.useCase, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Use title"), &data.useTitle, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Use subtitle"), &data.useSubtitle, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Use description"), &data.useDescription, trVDR("no"), trVDR("yes")));
// show Categories only if we have them
- if (SearchExtCats.Count() > 0)
- {
- Add(new cMenuEditBoolItem( tr("Use extended EPG info"), &data.useExtEPGInfo, trVDR("no"), trVDR("yes")));
- if (data.useExtEPGInfo)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- if (SearchExtCat->searchmode >= 10)
- Add(new cMenuEditIntItem(IndentMenuItem(SearchExtCat->menuname), &catvaluesNumeric[index], 0, 999999, ""));
- else
- Add(new cMenuEditStrItem( IndentMenuItem(SearchExtCat->menuname), data.catvalues[index], MaxFileName, tr(AllowedChars)));
-
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("Ignore missing categories")), &data.ignoreMissingEPGCats, trVDR("no"), trVDR("yes"))); }
+ if (SearchExtCats.Count() > 0) {
+ Add(new cMenuEditBoolItem(tr("Use extended EPG info"), &data.useExtEPGInfo, trVDR("no"), trVDR("yes")));
+ if (data.useExtEPGInfo) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ if (SearchExtCat->searchmode >= 10)
+ Add(new cMenuEditIntItem(IndentMenuItem(SearchExtCat->menuname), &catvaluesNumeric[index], 0, 999999, ""));
+ else
+ Add(new cMenuEditStrItem(IndentMenuItem(SearchExtCat->menuname), data.catvalues[index], MaxFileName, tr(AllowedChars)));
+
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("Ignore missing categories")), &data.ignoreMissingEPGCats, trVDR("no"), trVDR("yes")));
+ }
}
Add(new cMenuEditStraItem(tr("Use channel"), &data.useChannel, 4, UseChannelSel));
- if (data.useChannel==1)
- {
- Add(new cMenuEditChanItem(tr(" from channel"), &channelMin));
- Add(new cMenuEditChanItem(tr(" to channel"), &channelMax));
+ if (data.useChannel == 1) {
+ Add(new cMenuEditChanItem(tr(" from channel"), &channelMin));
+ Add(new cMenuEditChanItem(tr(" to channel"), &channelMax));
}
- if (data.useChannel==2)
- {
- // create the char array for the menu display
- if (menuitemsChGr) delete [] menuitemsChGr;
- menuitemsChGr = ChannelGroups.CreateMenuitemsList();
- int oldchannelGroupNr = channelGroupNr;
- channelGroupNr = ChannelGroups.GetIndex(channelGroupName);
- if (channelGroupNr == -1)
- {
- if (oldchannelGroupNr > 0 && oldchannelGroupNr <= ChannelGroups.Count()) // perhaps its name was changed
- channelGroupNr = oldchannelGroupNr;
- else
- channelGroupNr = 0; // no selection
- }
- else
- channelGroupNr++;
- Add(new cMenuEditStraItem(IndentMenuItem(tr("Channel group")), &channelGroupNr, ChannelGroups.Count()+1, menuitemsChGr));
+ if (data.useChannel == 2) {
+ // create the char array for the menu display
+ if (menuitemsChGr) delete [] menuitemsChGr;
+ menuitemsChGr = ChannelGroups.CreateMenuitemsList();
+ int oldchannelGroupNr = channelGroupNr;
+ channelGroupNr = ChannelGroups.GetIndex(channelGroupName);
+ if (channelGroupNr == -1) {
+ if (oldchannelGroupNr > 0 && oldchannelGroupNr <= ChannelGroups.Count()) // perhaps its name was changed
+ channelGroupNr = oldchannelGroupNr;
+ else
+ channelGroupNr = 0; // no selection
+ } else
+ channelGroupNr++;
+ Add(new cMenuEditStraItem(IndentMenuItem(tr("Channel group")), &channelGroupNr, ChannelGroups.Count() + 1, menuitemsChGr));
}
- Add(new cMenuEditBoolItem( tr("Use time"), &data.useTime, trVDR("no"), trVDR("yes")));
- if (data.useTime == true)
- {
- Add(new cMenuEditTimeItem(tr(" Start after"), &data.startTime));
- Add(new cMenuEditTimeItem(tr(" Start before"), &data.stopTime));
+ Add(new cMenuEditBoolItem(tr("Use time"), &data.useTime, trVDR("no"), trVDR("yes")));
+ if (data.useTime == true) {
+ Add(new cMenuEditTimeItem(tr(" Start after"), &data.startTime));
+ Add(new cMenuEditTimeItem(tr(" Start before"), &data.stopTime));
}
- Add(new cMenuEditBoolItem( tr("Use duration"), &data.useDuration, trVDR("no"), trVDR("yes")));
- if (data.useDuration == true)
- {
- Add(new cMenuEditTimeItem(tr(" Min. duration"), &data.minDuration));
- Add(new cMenuEditTimeItem(tr(" Max. duration"), &data.maxDuration));
+ Add(new cMenuEditBoolItem(tr("Use duration"), &data.useDuration, trVDR("no"), trVDR("yes")));
+ if (data.useDuration == true) {
+ Add(new cMenuEditTimeItem(tr(" Min. duration"), &data.minDuration));
+ Add(new cMenuEditTimeItem(tr(" Max. duration"), &data.maxDuration));
}
- Add(new cMenuEditBoolItem( tr("Use day of week"), &data.useDayOfWeek, trVDR("no"), trVDR("yes")));
- if (data.useDayOfWeek)
- {
- if (data.DayOfWeek < 0)
- {
- UserDefDayOfWeek = data.DayOfWeek;
- data.DayOfWeek = 7;
- }
- Add(new cMenuEditStraItem(IndentMenuItem(tr("Day of week")), &data.DayOfWeek, 8, DaysOfWeek));
+ Add(new cMenuEditBoolItem(tr("Use day of week"), &data.useDayOfWeek, trVDR("no"), trVDR("yes")));
+ if (data.useDayOfWeek) {
+ if (data.DayOfWeek < 0) {
+ UserDefDayOfWeek = data.DayOfWeek;
+ data.DayOfWeek = 7;
+ }
+ Add(new cMenuEditStraItem(IndentMenuItem(tr("Day of week")), &data.DayOfWeek, 8, DaysOfWeek));
}
- Add(new cMenuEditBoolItem( tr("Use global"), &data.isGlobal, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Use global"), &data.isGlobal, trVDR("no"), trVDR("yes")));
SetCurrent(Get(current));
}
@@ -224,21 +203,21 @@ void cMenuBlacklistEdit::Set()
cMenuBlacklistEdit::~cMenuBlacklistEdit()
{
if (blacklist && addIfConfirmed)
- delete blacklist; // apparently it wasn't confirmed
+ delete blacklist; // apparently it wasn't confirmed
if (menuitemsChGr)
- free(menuitemsChGr);
+ free(menuitemsChGr);
if (channelGroupName)
- free(channelGroupName);
+ free(channelGroupName);
if (catvaluesNumeric)
- free(catvaluesNumeric);
+ free(catvaluesNumeric);
int i;
- for(i=0; i<=4; i++)
- free(SearchModes[i]);
- for(i=0; i<=7; i++)
- free(DaysOfWeek[i]);
- for(i=0; i<=2; i++)
- free(UseChannelSel[i]);
+ for (i = 0; i <= 4; i++)
+ free(SearchModes[i]);
+ for (i = 0; i <= 7; i++)
+ free(DaysOfWeek[i]);
+ for (i = 0; i <= 2; i++)
+ free(UseChannelSel[i]);
}
eOSState cMenuBlacklistEdit::ProcessKey(eKeys Key)
@@ -255,25 +234,22 @@ eOSState cMenuBlacklistEdit::ProcessKey(eKeys Key)
eOSState state = cOsdMenu::ProcessKey(Key);
if (iTemp_mode != data.mode ||
- iTemp_useTime != data.useTime ||
- iTemp_useChannel != data.useChannel ||
- iTemp_useDuration != data.useDuration ||
- iTemp_useDayOfWeek != data.useDayOfWeek ||
- iTemp_useExtEPGInfo != data.useExtEPGInfo)
- {
- Set();
- Display();
+ iTemp_useTime != data.useTime ||
+ iTemp_useChannel != data.useChannel ||
+ iTemp_useDuration != data.useDuration ||
+ iTemp_useDayOfWeek != data.useDayOfWeek ||
+ iTemp_useExtEPGInfo != data.useExtEPGInfo) {
+ Set();
+ Display();
}
const char* ItemText = Get(Current())->Text();
- if (!HasSubMenu())
- {
- if (strlen(ItemText)>0 && strstr(ItemText, tr(" from channel")) == ItemText && ((Key >= k0 && Key <= k9) || Key == kLeft || Key == kRight))
- {
- channelMax = channelMin;
- Set();
- Display();
- }
+ if (!HasSubMenu()) {
+ if (strlen(ItemText) > 0 && strstr(ItemText, tr(" from channel")) == ItemText && ((Key >= k0 && Key <= k9) || Key == kLeft || Key == kRight)) {
+ channelMax = channelMin;
+ Set();
+ Display();
+ }
}
int iOnUserDefDayItem = 0;
@@ -284,180 +260,152 @@ eOSState cMenuBlacklistEdit::ProcessKey(eKeys Key)
int iCatIndex = -1;
char* catname = NULL;
- if (!HasSubMenu() && strlen(ItemText)>0)
- {
- // check, if on an item of ext. EPG info
- int iOnExtCatItem = 0;
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- if (strstr(ItemText, IndentMenuItem(SearchExtCat->menuname)) == ItemText)
- {
- iOnExtCatItem = 1;
- if (SearchExtCat->nvalues > 0)
- iOnExtCatItemBrowsable = 1;
- iCatIndex = index;
- catname = SearchExtCat->menuname;
- break;
- }
- index++;
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- }
-
- if (strstr(ItemText, tr("Search term")) == ItemText)
- {
- if (!InEditMode(ItemText, tr("Search term"), data.search)) // show template for a new search
- {
- SetHelp(NULL, NULL, NULL, tr("Button$Templates"));
- iOnTerm = 1;
- }
- }
- if (strstr(ItemText, IndentMenuItem(tr("Day of week"))) == ItemText)
- {
- if (data.DayOfWeek == 7)
- {
- SetHelp(trVDR("Button$Edit"));
- iOnUserDefDayItem = 1;
- }
- else
- SetHelp(NULL);
- }
- else if (strstr(ItemText, tr("Use channel")) == ItemText && data.useChannel == 2)
- {
- SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
- iOnUseChannelGroups = 1;
- }
- else if (strstr(ItemText, IndentMenuItem(tr("Channel group"))) == ItemText)
- {
- SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
- iOnChannelGroup = 1;
- }
- else if (iOnExtCatItem)
- {
- if (!InEditMode(ItemText, IndentMenuItem(catname), data.catvalues[iCatIndex]) ||
- SearchExtCats.Get(iCatIndex)->searchmode >= 10)
- SetHelp(NULL, NULL, NULL, iOnExtCatItemBrowsable?tr("Button$Select"):NULL);
- }
- else if (strstr(ItemText, tr("Search term")) != ItemText)
- SetHelp(NULL, NULL, NULL, NULL);
+ if (!HasSubMenu() && strlen(ItemText) > 0) {
+ // check, if on an item of ext. EPG info
+ int iOnExtCatItem = 0;
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ if (strstr(ItemText, IndentMenuItem(SearchExtCat->menuname)) == ItemText) {
+ iOnExtCatItem = 1;
+ if (SearchExtCat->nvalues > 0)
+ iOnExtCatItemBrowsable = 1;
+ iCatIndex = index;
+ catname = SearchExtCat->menuname;
+ break;
+ }
+ index++;
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ }
+
+ if (strstr(ItemText, tr("Search term")) == ItemText) {
+ if (!InEditMode(ItemText, tr("Search term"), data.search)) { // show template for a new search
+ SetHelp(NULL, NULL, NULL, tr("Button$Templates"));
+ iOnTerm = 1;
+ }
+ }
+ if (strstr(ItemText, IndentMenuItem(tr("Day of week"))) == ItemText) {
+ if (data.DayOfWeek == 7) {
+ SetHelp(trVDR("Button$Edit"));
+ iOnUserDefDayItem = 1;
+ } else
+ SetHelp(NULL);
+ } else if (strstr(ItemText, tr("Use channel")) == ItemText && data.useChannel == 2) {
+ SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
+ iOnUseChannelGroups = 1;
+ } else if (strstr(ItemText, IndentMenuItem(tr("Channel group"))) == ItemText) {
+ SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
+ iOnChannelGroup = 1;
+ } else if (iOnExtCatItem) {
+ if (!InEditMode(ItemText, IndentMenuItem(catname), data.catvalues[iCatIndex]) ||
+ SearchExtCats.Get(iCatIndex)->searchmode >= 10)
+ SetHelp(NULL, NULL, NULL, iOnExtCatItemBrowsable ? tr("Button$Select") : NULL);
+ } else if (strstr(ItemText, tr("Search term")) != ItemText)
+ SetHelp(NULL, NULL, NULL, NULL);
}
if (state == osUnknown) {
- if (HasSubMenu())
- return osContinue;
- switch (Key) {
- case kOk:
- if (data.useChannel==1)
- {
- LOCK_CHANNELS_READ;
- const cChannel *ch = Channels->GetByNumber(channelMin);
- if (ch)
- data.channelMin = ch;
- else
- {
- ERROR(tr("*** Invalid Channel ***"));
- break;
- }
- ch = Channels->GetByNumber(channelMax);
- if (ch)
- data.channelMax = ch;
- else
- {
- ERROR(tr("*** Invalid Channel ***"));
- break;
- }
- if (channelMin > channelMax)
- {
- ERROR(tr("Please check channel criteria!"));
- return osContinue;
- }
- }
- if (data.useChannel==2)
- data.channelGroup = strdup(menuitemsChGr[channelGroupNr]);
-
- if (blacklist)
- {
- *blacklist = data;
- if (data.DayOfWeek == 7)
- blacklist->DayOfWeek = UserDefDayOfWeek;
-
- // transfer numeric cat values back to search
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- if (SearchExtCat->searchmode >= 10)
- {
- if (blacklist->catvalues[index]) free(blacklist->catvalues[index]);
- msprintf(&blacklist->catvalues[index], "%d", catvaluesNumeric[index]);
- }
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
-
- if (addIfConfirmed)
- {
- cMutexLock BlacklistLock(&Blacklists);
- blacklist->ID = Blacklists.GetNewID();
- Blacklists.Add(blacklist);
- }
-
- Blacklists.Save();
- addIfConfirmed = false;
- }
- return osBack;
- case kRed:
- if (iOnUserDefDayItem)
- state = AddSubMenu(new cMenuEditDaysOfWeek(&UserDefDayOfWeek));
- break;
-
- case kBlue:
- if (iOnUseChannelGroups || iOnChannelGroup)
- {
- if (channelGroupName)
- free(channelGroupName);
- channelGroupName = strdup(menuitemsChGr[channelGroupNr]);
- state = AddSubMenu(new cMenuChannelGroups(&channelGroupName));
- }
- if (iOnTerm)
- state = AddSubMenu(new cMenuEPGSearchTemplate(NULL, &data, addIfConfirmed));
- if (iOnExtCatItemBrowsable)
- state = AddSubMenu(new cMenuCatValuesSelect(data.catvalues[iCatIndex], iCatIndex, SearchExtCats.Get(iCatIndex)->searchmode));
- break;
- case kGreen:
- case kYellow: state = osContinue;
- default: break;
- }
+ if (HasSubMenu())
+ return osContinue;
+ switch (Key) {
+ case kOk:
+ if (data.useChannel == 1) {
+ LOCK_CHANNELS_READ;
+ const cChannel *ch = Channels->GetByNumber(channelMin);
+ if (ch)
+ data.channelMin = ch;
+ else {
+ ERROR(tr("*** Invalid Channel ***"));
+ break;
+ }
+ ch = Channels->GetByNumber(channelMax);
+ if (ch)
+ data.channelMax = ch;
+ else {
+ ERROR(tr("*** Invalid Channel ***"));
+ break;
+ }
+ if (channelMin > channelMax) {
+ ERROR(tr("Please check channel criteria!"));
+ return osContinue;
+ }
+ }
+ if (data.useChannel == 2)
+ data.channelGroup = strdup(menuitemsChGr[channelGroupNr]);
+
+ if (blacklist) {
+ *blacklist = data;
+ if (data.DayOfWeek == 7)
+ blacklist->DayOfWeek = UserDefDayOfWeek;
+
+ // transfer numeric cat values back to search
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ if (SearchExtCat->searchmode >= 10) {
+ if (blacklist->catvalues[index]) free(blacklist->catvalues[index]);
+ msprintf(&blacklist->catvalues[index], "%d", catvaluesNumeric[index]);
+ }
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+
+ if (addIfConfirmed) {
+ cMutexLock BlacklistLock(&Blacklists);
+ blacklist->ID = Blacklists.GetNewID();
+ Blacklists.Add(blacklist);
+ }
+
+ Blacklists.Save();
+ addIfConfirmed = false;
+ }
+ return osBack;
+ case kRed:
+ if (iOnUserDefDayItem)
+ state = AddSubMenu(new cMenuEditDaysOfWeek(&UserDefDayOfWeek));
+ break;
+
+ case kBlue:
+ if (iOnUseChannelGroups || iOnChannelGroup) {
+ if (channelGroupName)
+ free(channelGroupName);
+ channelGroupName = strdup(menuitemsChGr[channelGroupNr]);
+ state = AddSubMenu(new cMenuChannelGroups(&channelGroupName));
+ }
+ if (iOnTerm)
+ state = AddSubMenu(new cMenuEPGSearchTemplate(NULL, &data, addIfConfirmed));
+ if (iOnExtCatItemBrowsable)
+ state = AddSubMenu(new cMenuCatValuesSelect(data.catvalues[iCatIndex], iCatIndex, SearchExtCats.Get(iCatIndex)->searchmode));
+ break;
+ case kGreen:
+ case kYellow:
+ state = osContinue;
+ default:
+ break;
+ }
}
- if ((iOnUseChannelGroups || iOnChannelGroup || iOnTerm || iOnExtCatItemBrowsable) && bHadSubMenu && !HasSubMenu()) // return form submenu
- {
- if (iOnTerm)
- {
- if (data.DayOfWeek < 0)
- {
- UserDefDayOfWeek = data.DayOfWeek;
- data.DayOfWeek = 7;
- }
- if (data.useChannel == 2)
- {
- channelGroupNr = ChannelGroups.GetIndex(data.channelGroup);
- channelGroupName = strdup(data.channelGroup);
- }
- }
- if (iOnExtCatItemBrowsable && SearchExtCats.Count() > 0)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- if (SearchExtCat->searchmode >= 10)
- catvaluesNumeric[index] = atoi(data.catvalues[index]);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- }
- Set();
- Display();
+ if ((iOnUseChannelGroups || iOnChannelGroup || iOnTerm || iOnExtCatItemBrowsable) && bHadSubMenu && !HasSubMenu()) { // return form submenu
+ if (iOnTerm) {
+ if (data.DayOfWeek < 0) {
+ UserDefDayOfWeek = data.DayOfWeek;
+ data.DayOfWeek = 7;
+ }
+ if (data.useChannel == 2) {
+ channelGroupNr = ChannelGroups.GetIndex(data.channelGroup);
+ channelGroupName = strdup(data.channelGroup);
+ }
+ }
+ if (iOnExtCatItemBrowsable && SearchExtCats.Count() > 0) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ if (SearchExtCat->searchmode >= 10)
+ catvaluesNumeric[index] = atoi(data.catvalues[index]);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+ }
+ Set();
+ Display();
}
return state;
}
diff --git a/menu_blacklistedit.h b/menu_blacklistedit.h
index dc64778..486d076 100644
--- a/menu_blacklistedit.h
+++ b/menu_blacklistedit.h
@@ -27,29 +27,30 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "blacklist.h"
// --- cMenuBlacklistEdit --------------------------------------------------------
-class cMenuBlacklistEdit: public cOsdMenu {
+class cMenuBlacklistEdit: public cOsdMenu
+{
protected:
- cBlacklist *blacklist;
- cBlacklist data;
- int channelMin;
- int channelMax;
- bool addIfConfirmed;
- int UserDefDayOfWeek;
- int channelGroupNr;
- char* channelGroupName;
- char** menuitemsChGr;
- int* catvaluesNumeric;
-
- char *SearchModes[6];
- char *DaysOfWeek[8];
- char *UseChannelSel[4];
-
- public:
- cMenuBlacklistEdit(cBlacklist *Blacklist, bool New = false);
- virtual eOSState ProcessKey(eKeys Key);
- virtual ~cMenuBlacklistEdit();
- virtual void Set();
- void CreateMenuitemsChannelGroups();
+ cBlacklist *blacklist;
+ cBlacklist data;
+ int channelMin;
+ int channelMax;
+ bool addIfConfirmed;
+ int UserDefDayOfWeek;
+ int channelGroupNr;
+ char* channelGroupName;
+ char** menuitemsChGr;
+ int* catvaluesNumeric;
+
+ char *SearchModes[6];
+ char *DaysOfWeek[8];
+ char *UseChannelSel[4];
+
+public:
+ cMenuBlacklistEdit(cBlacklist *Blacklist, bool New = false);
+ virtual eOSState ProcessKey(eKeys Key);
+ virtual ~cMenuBlacklistEdit();
+ virtual void Set();
+ void CreateMenuitemsChannelGroups();
};
#endif
diff --git a/menu_blacklists.c b/menu_blacklists.c
index 5290484..b0567a9 100644
--- a/menu_blacklists.c
+++ b/menu_blacklists.c
@@ -35,14 +35,15 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
using namespace std;
// --- cMenuBlacklistsItem ----------------------------------------------------------
-class cMenuBlacklistsItem : public cOsdItem {
- private:
+class cMenuBlacklistsItem : public cOsdItem
+{
+private:
public:
- cBlacklist* blacklist;
- cMenuBlacklistsItem(cBlacklist* Blacklist);
- int Compare(const cListObject &ListObject) const;
- void Set(void);
- };
+ cBlacklist* blacklist;
+ cMenuBlacklistsItem(cBlacklist* Blacklist);
+ int Compare(const cListObject &ListObject) const;
+ void Set(void);
+};
cMenuBlacklistsItem::cMenuBlacklistsItem(cBlacklist* Blacklist)
{
@@ -52,59 +53,55 @@ cMenuBlacklistsItem::cMenuBlacklistsItem(cBlacklist* Blacklist)
void cMenuBlacklistsItem::Set(void)
{
- ostringstream line;
-
- if (blacklist->isGlobal != 0)
- line << setiosflags(ios::left) << "G";
- line << "\t";
-
- if (blacklist->search && strlen(blacklist->search) > 0)
- line << setiosflags(ios::left) << string(blacklist->search);
- else
- line << setiosflags(ios::left) << "*";
-
- line << "\t";
- if (blacklist->useChannel == 1)
- {
- if (blacklist->channelMin != blacklist->channelMax)
- line << setiosflags(ios::left) << blacklist->channelMin->Number() << " - " << blacklist->channelMax->Number();
- else
- line << setiosflags(ios::left) << setw(11) << (blacklist->useChannel?CHANNELNAME(blacklist->channelMin):"");
- }
- else if (blacklist->useChannel == 2)
- line << setiosflags(ios::left) << setw(11) << blacklist->channelGroup;
-
- line << "\t";
- if (blacklist->useTime)
- {
- ostringstream timeline;
- timeline << setfill('0') << setw(2) << blacklist->startTime / 100 << ":" << setw(2) << blacklist->startTime % 100;
- timeline << "\t";
- timeline << setfill('0') << setw(2) << blacklist->stopTime / 100 << ":" << setw(2) << blacklist->stopTime % 100;
- line << timeline.str();
- }
- else
- line << "--:--\t--:--";
-
- SetText(strdup(line.str().c_str()), false);
+ ostringstream line;
+
+ if (blacklist->isGlobal != 0)
+ line << setiosflags(ios::left) << "G";
+ line << "\t";
+
+ if (blacklist->search && strlen(blacklist->search) > 0)
+ line << setiosflags(ios::left) << string(blacklist->search);
+ else
+ line << setiosflags(ios::left) << "*";
+
+ line << "\t";
+ if (blacklist->useChannel == 1) {
+ if (blacklist->channelMin != blacklist->channelMax)
+ line << setiosflags(ios::left) << blacklist->channelMin->Number() << " - " << blacklist->channelMax->Number();
+ else
+ line << setiosflags(ios::left) << setw(11) << (blacklist->useChannel ? CHANNELNAME(blacklist->channelMin) : "");
+ } else if (blacklist->useChannel == 2)
+ line << setiosflags(ios::left) << setw(11) << blacklist->channelGroup;
+
+ line << "\t";
+ if (blacklist->useTime) {
+ ostringstream timeline;
+ timeline << setfill('0') << setw(2) << blacklist->startTime / 100 << ":" << setw(2) << blacklist->startTime % 100;
+ timeline << "\t";
+ timeline << setfill('0') << setw(2) << blacklist->stopTime / 100 << ":" << setw(2) << blacklist->stopTime % 100;
+ line << timeline.str();
+ } else
+ line << "--:--\t--:--";
+
+ SetText(strdup(line.str().c_str()), false);
}
int cMenuBlacklistsItem::Compare(const cListObject &ListObject) const
{
- cMenuBlacklistsItem *p = (cMenuBlacklistsItem *)&ListObject;
- return strcasecmp(blacklist->search, p->blacklist->search);
+ cMenuBlacklistsItem *p = (cMenuBlacklistsItem *)&ListObject;
+ return strcasecmp(blacklist->search, p->blacklist->search);
}
// --- cMenuBlacklists ----------------------------------------------------------
cMenuBlacklists::cMenuBlacklists()
-:cOsdMenu(tr("Blacklists"), 3, 20, 11, 6, 5)
+ : cOsdMenu(tr("Blacklists"), 3, 20, 11, 6, 5)
{
- SetMenuCategory(mcSetupPlugins);
+ SetMenuCategory(mcSetupPlugins);
cMutexLock BlacklistLock(&Blacklists);
cBlacklist *Blacklist = Blacklists.First();
while (Blacklist) {
- Add(new cMenuBlacklistsItem(Blacklist));
- Blacklist = Blacklists.Next(Blacklist);
+ Add(new cMenuBlacklistsItem(Blacklist));
+ Blacklist = Blacklists.Next(Blacklist);
}
SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), NULL);
Sort();
@@ -116,14 +113,14 @@ cBlacklist *cMenuBlacklists::CurrentBlacklist(void)
{
cMenuBlacklistsItem *item = (cMenuBlacklistsItem *)Get(Current());
if (item && Blacklists.Exists(item->blacklist))
- return item->blacklist;
+ return item->blacklist;
return NULL;
}
eOSState cMenuBlacklists::New(void)
{
if (HasSubMenu())
- return osContinue;
+ return osContinue;
return AddSubMenu(new cMenuBlacklistEdit(new cBlacklist, true));
}
@@ -131,61 +128,63 @@ eOSState cMenuBlacklists::Delete(void)
{
cBlacklist *curBlacklist = CurrentBlacklist();
if (curBlacklist) {
- if (Interface->Confirm(tr("Edit$Delete blacklist?"))) {
- LogFile.Log(1,"blacklist %s (%d) deleted", curBlacklist->search, curBlacklist->ID);
- SearchExts.RemoveBlacklistID(curBlacklist->ID);
- cMutexLock BlacklistLock(&Blacklists);
- Blacklists.Del(curBlacklist);
- Blacklists.Save();
- cOsdMenu::Del(Current());
- Display();
- }
+ if (Interface->Confirm(tr("Edit$Delete blacklist?"))) {
+ LogFile.Log(1, "blacklist %s (%d) deleted", curBlacklist->search, curBlacklist->ID);
+ SearchExts.RemoveBlacklistID(curBlacklist->ID);
+ cMutexLock BlacklistLock(&Blacklists);
+ Blacklists.Del(curBlacklist);
+ Blacklists.Save();
+ cOsdMenu::Del(Current());
+ Display();
+ }
}
return osContinue;
}
eOSState cMenuBlacklists::ProcessKey(eKeys Key)
{
- int BlacklistNumber = HasSubMenu() ? Count() : -1;
- eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown) {
- if (HasSubMenu())
- return osContinue;
- switch (Key) {
- case kOk:
- return AddSubMenu(new cMenuSearchResultsForBlacklist(CurrentBlacklist()));
- break;
- case kRed:
- if (CurrentBlacklist())
- state = AddSubMenu(new cMenuBlacklistEdit(CurrentBlacklist()));
- else
- state = osContinue;
- break;
- case kGreen: state = New(); break;
- case kYellow: state = Delete(); break;
- default: break;
- }
- }
- if (BlacklistNumber >= 0 && !HasSubMenu())
- {
- cMutexLock BlacklistLock(&Blacklists);
- cBlacklist* Blacklist = Blacklists.Get(BlacklistNumber);
- if (Blacklist) // a newly created search was confirmed with Ok
- Add(new cMenuBlacklistsItem(Blacklist));
- // always update all entries, since channel group names may have changed and affect other searches
- Sort();
- for(int i=0; i<Count(); i++)
- {
- cMenuBlacklistsItem *item = (cMenuBlacklistsItem *)Get(i);
- if (item)
- {
- item->Set();
- if (item->blacklist == Blacklist)
- SetCurrent(item);
- }
- }
- Display();
- }
-
- return state;
+ int BlacklistNumber = HasSubMenu() ? Count() : -1;
+ eOSState state = cOsdMenu::ProcessKey(Key);
+ if (state == osUnknown) {
+ if (HasSubMenu())
+ return osContinue;
+ switch (Key) {
+ case kOk:
+ return AddSubMenu(new cMenuSearchResultsForBlacklist(CurrentBlacklist()));
+ break;
+ case kRed:
+ if (CurrentBlacklist())
+ state = AddSubMenu(new cMenuBlacklistEdit(CurrentBlacklist()));
+ else
+ state = osContinue;
+ break;
+ case kGreen:
+ state = New();
+ break;
+ case kYellow:
+ state = Delete();
+ break;
+ default:
+ break;
+ }
+ }
+ if (BlacklistNumber >= 0 && !HasSubMenu()) {
+ cMutexLock BlacklistLock(&Blacklists);
+ cBlacklist* Blacklist = Blacklists.Get(BlacklistNumber);
+ if (Blacklist) // a newly created search was confirmed with Ok
+ Add(new cMenuBlacklistsItem(Blacklist));
+ // always update all entries, since channel group names may have changed and affect other searches
+ Sort();
+ for (int i = 0; i < Count(); i++) {
+ cMenuBlacklistsItem *item = (cMenuBlacklistsItem *)Get(i);
+ if (item) {
+ item->Set();
+ if (item->blacklist == Blacklist)
+ SetCurrent(item);
+ }
+ }
+ Display();
+ }
+
+ return state;
}
diff --git a/menu_blacklists.h b/menu_blacklists.h
index b10bbfa..bf1b823 100644
--- a/menu_blacklists.h
+++ b/menu_blacklists.h
@@ -27,13 +27,14 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include <vdr/plugin.h>
#include "blacklist.h"
-class cMenuBlacklists : public cOsdMenu {
- private:
+class cMenuBlacklists : public cOsdMenu
+{
+private:
eOSState New(void);
eOSState Delete(void);
- protected:
+protected:
virtual eOSState ProcessKey(eKeys Key);
- public:
+public:
cMenuBlacklists();
cBlacklist* CurrentBlacklist(void);
};
diff --git a/menu_commands.c b/menu_commands.c
index ef20c11..99ca744 100644
--- a/menu_commands.c
+++ b/menu_commands.c
@@ -43,31 +43,30 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
// --- cMenuSearchCommands ---------------------------------------------------------
cMenuSearchCommands::cMenuSearchCommands(const char *Title, const cEvent* Event, bool DirectCall, cSearchExt* Search)
-:cOsdMenu(Title)
+ : cOsdMenu(Title)
{
- SetMenuCategory(mcCommand);
-
- directCall = DirectCall;
- SetHasHotkeys();
- LoadCommands();
-
- search = Search;
- event = Event;
- Add(new cOsdItem(hk(tr("Repeats"))));
- Add(new cOsdItem(hk(trVDR("Button$Record"))));
- Add(new cOsdItem(hk(trVDR("Button$Switch"))));
- Add(new cOsdItem(hk(tr("Create search"))));
- Add(new cOsdItem(hk(tr("Search in recordings"))));
- Add(new cOsdItem(hk(tr("Mark as 'already recorded'?"))));
- Add(new cOsdItem(hk(tr("Add/Remove to/from switch list?"))));
- Add(new cOsdItem(hk(tr("Create blacklist"))));
- for (cCommand *command = commands.First(); command; command = commands.Next(command))
- Add(new cOsdItem(hk(command->Title())));
- if (event)
- {
- cString szTitle = cString::sprintf("%s: %s", tr("EPG Commands"), event->Title());
- SetTitle(szTitle);
- }
+ SetMenuCategory(mcCommand);
+
+ directCall = DirectCall;
+ SetHasHotkeys();
+ LoadCommands();
+
+ search = Search;
+ event = Event;
+ Add(new cOsdItem(hk(tr("Repeats"))));
+ Add(new cOsdItem(hk(trVDR("Button$Record"))));
+ Add(new cOsdItem(hk(trVDR("Button$Switch"))));
+ Add(new cOsdItem(hk(tr("Create search"))));
+ Add(new cOsdItem(hk(tr("Search in recordings"))));
+ Add(new cOsdItem(hk(tr("Mark as 'already recorded'?"))));
+ Add(new cOsdItem(hk(tr("Add/Remove to/from switch list?"))));
+ Add(new cOsdItem(hk(tr("Create blacklist"))));
+ for (cCommand *command = commands.First(); command; command = commands.Next(command))
+ Add(new cOsdItem(hk(command->Title())));
+ if (event) {
+ cString szTitle = cString::sprintf("%s: %s", tr("EPG Commands"), event->Title());
+ SetTitle(szTitle);
+ }
}
cMenuSearchCommands::~cMenuSearchCommands()
@@ -76,257 +75,243 @@ cMenuSearchCommands::~cMenuSearchCommands()
void cMenuSearchCommands::LoadCommands()
{
- const char* szLanguageCode = I18nLanguageCode(I18nCurrentLanguage());
-
- char *pstrSearchToken, *pptr;
- char *pstrSearch=strdup(szLanguageCode);
- pstrSearchToken=strtok_r(pstrSearch, ",", &pptr);
- bool bLoaded = false;
- while(pstrSearchToken) // may contain multiple code, e.g. 'ger,deu'
- {
- cString cmdFile = cString::sprintf("%s-%s.conf", ADDDIR(CONFIGDIR, "epgsearchcmds"), pstrSearchToken);
- if (access(cmdFile, F_OK) == 0)
- {
- commands.Load(cmdFile, true);
- bLoaded = true;
- break;
- }
- pstrSearchToken=strtok_r(NULL, ",", &pptr);
- }
- if (!bLoaded)
- commands.Load(AddDirectory(CONFIGDIR, "epgsearchcmds.conf"), true);
- free(pstrSearch);
+ const char* szLanguageCode = I18nLanguageCode(I18nCurrentLanguage());
+
+ char *pstrSearchToken, *pptr;
+ char *pstrSearch = strdup(szLanguageCode);
+ pstrSearchToken = strtok_r(pstrSearch, ",", &pptr);
+ bool bLoaded = false;
+ while (pstrSearchToken) { // may contain multiple code, e.g. 'ger,deu'
+ cString cmdFile = cString::sprintf("%s-%s.conf", ADDDIR(CONFIGDIR, "epgsearchcmds"), pstrSearchToken);
+ if (access(cmdFile, F_OK) == 0) {
+ commands.Load(cmdFile, true);
+ bLoaded = true;
+ break;
+ }
+ pstrSearchToken = strtok_r(NULL, ",", &pptr);
+ }
+ if (!bLoaded)
+ commands.Load(AddDirectory(CONFIGDIR, "epgsearchcmds.conf"), true);
+ free(pstrSearch);
}
eOSState cMenuSearchCommands::Switch(void)
{
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(event->ChannelID(), true, true);
- if (channel && cDevice::PrimaryDevice()->SwitchChannel(channel, true))
- return osEnd;
- else
- {
- INFO(trVDR("Can't switch channel!"));
- return osContinue;
- }
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(event->ChannelID(), true, true);
+ if (channel && cDevice::PrimaryDevice()->SwitchChannel(channel, true))
+ return osEnd;
+ else {
+ INFO(trVDR("Can't switch channel!"));
+ return osContinue;
+ }
}
eOSState cMenuSearchCommands::ExtendedSearch(void)
{
- return AddSubMenu(new cMenuEPGSearchExt());
+ return AddSubMenu(new cMenuEPGSearchExt());
}
eOSState cMenuSearchCommands::Record(void)
{
- if (!event) return osContinue;
-
- eTimerMatch timerMatch = tmNone;
- LOCK_TIMERS_WRITE;
- Timers->SetExplicitModify();
- cTimer* timer = Timers->GetMatch(event, &timerMatch);
- if (timerMatch == tmFull)
- {
- if (EPGSearchConfig.useVDRTimerEditMenu)
- return AddSubMenu(new cMenuEditTimer(timer));
- else
- return AddSubMenu(new cMenuMyEditTimer(timer, false, event, timer->Channel()));
- }
-
- timer = new cTimer(event);
- PrepareTimerFile(event, timer);
- cTimer *t = Timers->GetTimer(timer);
-
- if (EPGSearchConfig.onePressTimerCreation == 0 || t || (!t && event->StartTime() - (Setup.MarginStart+2) * 60 < time(NULL)))
- {
- if (t)
- {
- delete timer;
- timer = t;
- }
- if (EPGSearchConfig.useVDRTimerEditMenu)
- return AddSubMenu(new cMenuEditTimer(timer, !t));
- else
- return AddSubMenu(new cMenuMyEditTimer(timer, !t, event));
- }
- else
- {
- string fullaux = "";
- string aux = "";
- if (event)
- {
- int bstart = event->StartTime() - timer->StartTime();
- int bstop = timer->StopTime() - event->EndTime();
- int checkmode = DefTimerCheckModes.GetMode(timer->Channel());
- aux = UpdateAuxValue(aux, "channel", NumToString(timer->Channel()->Number()) + " - " + CHANNELNAME(timer->Channel()));
- aux = UpdateAuxValue(aux, "update", checkmode);
- aux = UpdateAuxValue(aux, "eventid", event->EventID());
- aux = UpdateAuxValue(aux, "bstart", bstart);
- aux = UpdateAuxValue(aux, "bstop", bstop);
- fullaux = UpdateAuxValue(fullaux, "epgsearch", aux);
- }
+ if (!event) return osContinue;
+
+ eTimerMatch timerMatch = tmNone;
+ LOCK_TIMERS_WRITE;
+ Timers->SetExplicitModify();
+ cTimer* timer = Timers->GetMatch(event, &timerMatch);
+ if (timerMatch == tmFull) {
+ if (EPGSearchConfig.useVDRTimerEditMenu)
+ return AddSubMenu(new cMenuEditTimer(timer));
+ else
+ return AddSubMenu(new cMenuMyEditTimer(timer, false, event, timer->Channel()));
+ }
+
+ timer = new cTimer(event);
+ PrepareTimerFile(event, timer);
+ cTimer *t = Timers->GetTimer(timer);
+
+ if (EPGSearchConfig.onePressTimerCreation == 0 || t || (!t && event->StartTime() - (Setup.MarginStart + 2) * 60 < time(NULL))) {
+ if (t) {
+ delete timer;
+ timer = t;
+ }
+ if (EPGSearchConfig.useVDRTimerEditMenu)
+ return AddSubMenu(new cMenuEditTimer(timer, !t));
+ else
+ return AddSubMenu(new cMenuMyEditTimer(timer, !t, event));
+ } else {
+ string fullaux = "";
+ string aux = "";
+ if (event) {
+ int bstart = event->StartTime() - timer->StartTime();
+ int bstop = timer->StopTime() - event->EndTime();
+ int checkmode = DefTimerCheckModes.GetMode(timer->Channel());
+ aux = UpdateAuxValue(aux, "channel", NumToString(timer->Channel()->Number()) + " - " + CHANNELNAME(timer->Channel()));
+ aux = UpdateAuxValue(aux, "update", checkmode);
+ aux = UpdateAuxValue(aux, "eventid", event->EventID());
+ aux = UpdateAuxValue(aux, "bstart", bstart);
+ aux = UpdateAuxValue(aux, "bstop", bstop);
+ fullaux = UpdateAuxValue(fullaux, "epgsearch", aux);
+ }
#ifdef USE_PINPLUGIN
- aux = "";
- aux = UpdateAuxValue(aux, "protected", timer->FskProtection() ? "yes" : "no");
- fullaux = UpdateAuxValue(fullaux, "pin-plugin", aux);
+ aux = "";
+ aux = UpdateAuxValue(aux, "protected", timer->FskProtection() ? "yes" : "no");
+ fullaux = UpdateAuxValue(fullaux, "pin-plugin", aux);
#endif
- SetAux(timer, fullaux);
- if (Setup.SVDRPPeering && *Setup.SVDRPDefaultHost)
- timer->SetRemote(Setup.SVDRPDefaultHost);
- Timers->Add(timer);
- timer->Matches();
- Timers->SetModified();
- if (!HandleRemoteTimerModifications(timer)) {
- ERROR(tr("Epgsearch: RemoteTimerModifications failed"));
- Timers->Del(timer);
- }
- else
- return osBack;
- }
- return osContinue;
+ SetAux(timer, fullaux);
+ if (Setup.SVDRPPeering && *Setup.SVDRPDefaultHost)
+ timer->SetRemote(Setup.SVDRPDefaultHost);
+ Timers->Add(timer);
+ timer->Matches();
+ Timers->SetModified();
+ if (!HandleRemoteTimerModifications(timer)) {
+ ERROR(tr("Epgsearch: RemoteTimerModifications failed"));
+ Timers->Del(timer);
+ } else
+ return osBack;
+ }
+ return osContinue;
}
eOSState cMenuSearchCommands::MarkAsRecorded(void)
{
- if (!event) return osContinue;
- if (!Interface->Confirm(tr("Mark as 'already recorded'?")))
- return osContinue;
- cTimer* dummyTimer = new cTimer(event);
- cMutexLock RecsDoneLock(&RecsDone);
- RecsDone.Add(new cRecDone(dummyTimer, event, search));
- RecsDone.Save();
- delete dummyTimer;
- return osBack;
+ if (!event) return osContinue;
+ if (!Interface->Confirm(tr("Mark as 'already recorded'?")))
+ return osContinue;
+ cTimer* dummyTimer = new cTimer(event);
+ cMutexLock RecsDoneLock(&RecsDone);
+ RecsDone.Add(new cRecDone(dummyTimer, event, search));
+ RecsDone.Save();
+ delete dummyTimer;
+ return osBack;
}
eOSState cMenuSearchCommands::AddToSwitchList(void)
{
- if (!event) return osContinue;
-
- time_t now = time(NULL);
- if (now >= event->StartTime())
- {
- ERROR(tr("Already running!"));
- return osBack;
- }
- cSwitchTimer* switchTimer = SwitchTimers.InSwitchList(event);
- if (!switchTimer)
- {
- if (!Interface->Confirm(tr("Add to switch list?")))
- return osContinue;
- cMutexLock SwitchTimersLock(&SwitchTimers);
- SwitchTimers.Add(new cSwitchTimer(event));
- SwitchTimers.Save();
- cSwitchTimerThread::Init(); // asure the thread is running
- }
- else
- {
- if (!Interface->Confirm(tr("Delete from switch list?")))
- return osContinue;
- cMutexLock SwitchTimersLock(&SwitchTimers);
- SwitchTimers.Del(switchTimer);
- SwitchTimers.Save();
- if (SwitchTimers.Count() == 0)
- cSwitchTimerThread::Exit();
- }
- return osBack;
+ if (!event) return osContinue;
+
+ time_t now = time(NULL);
+ if (now >= event->StartTime()) {
+ ERROR(tr("Already running!"));
+ return osBack;
+ }
+ cSwitchTimer* switchTimer = SwitchTimers.InSwitchList(event);
+ if (!switchTimer) {
+ if (!Interface->Confirm(tr("Add to switch list?")))
+ return osContinue;
+ cMutexLock SwitchTimersLock(&SwitchTimers);
+ SwitchTimers.Add(new cSwitchTimer(event));
+ SwitchTimers.Save();
+ cSwitchTimerThread::Init(); // asure the thread is running
+ } else {
+ if (!Interface->Confirm(tr("Delete from switch list?")))
+ return osContinue;
+ cMutexLock SwitchTimersLock(&SwitchTimers);
+ SwitchTimers.Del(switchTimer);
+ SwitchTimers.Save();
+ if (SwitchTimers.Count() == 0)
+ cSwitchTimerThread::Exit();
+ }
+ return osBack;
}
eOSState cMenuSearchCommands::CreateSearchTimer(void)
{
- if (!event) return osContinue;
+ if (!event) return osContinue;
- cSearchExt* pNew = new cSearchExt;
- strcpy(pNew->search, event->Title());
- LOCK_CHANNELS_READ;
- pNew->channelMin = pNew->channelMax = Channels->GetByChannelID(event->ChannelID());
- return AddSubMenu(new cMenuEditSearchExt(pNew, true, false, true));
+ cSearchExt* pNew = new cSearchExt;
+ strcpy(pNew->search, event->Title());
+ LOCK_CHANNELS_READ;
+ pNew->channelMin = pNew->channelMax = Channels->GetByChannelID(event->ChannelID());
+ return AddSubMenu(new cMenuEditSearchExt(pNew, true, false, true));
}
eOSState cMenuSearchCommands::CreateBlacklist(void)
{
- if (!event) return osContinue;
+ if (!event) return osContinue;
- cBlacklist* pNew = new cBlacklist;
- strcpy(pNew->search, event->Title());
- return AddSubMenu(new cMenuBlacklistEdit(pNew, true));
+ cBlacklist* pNew = new cBlacklist;
+ strcpy(pNew->search, event->Title());
+ return AddSubMenu(new cMenuBlacklistEdit(pNew, true));
}
eOSState cMenuSearchCommands::Execute(void)
{
- int current = Current();
- if (current <= 7)
- {
- if (current == 0)
- return AddSubMenu(new cMenuSearchResultsForQuery(event->Title(), true));
- if (current == 1)
- return Record();
- if (current == 2)
- return Switch();
- if (current == 3)
- return CreateSearchTimer();
- if (current == 4)
- return AddSubMenu(new cMenuSearchResultsForRecs(event->Title()));
- if (current == 5)
- return MarkAsRecorded();
- if (current == 6)
- return AddToSwitchList();
- if (current == 7)
- return CreateBlacklist();
- }
-
- cCommand *command = commands.Get(current-8);
- if (command) {
- cString buffer;
- bool confirmed = true;
- if (command->Confirm()) {
- buffer = cString::sprintf("%s?", command->Title());
- confirmed = Interface->Confirm(buffer);
- }
- if (confirmed) {
- buffer = cString::sprintf("%s...", command->Title());
- Skins.Message(mtStatus, buffer);
-
- {
- LOCK_CHANNELS_READ;
- buffer = cString::sprintf("'%s' %ld %ld %d '%s' '%s'",
- EscapeString(event->Title()).c_str(),
- event->StartTime(),
- event->EndTime(),
- ChannelNrFromEvent(event),
- EscapeString(Channels->GetByChannelID(event->ChannelID(), true, true)->Name()).c_str(),
- EscapeString(event->ShortText()?event->ShortText():"").c_str());
- }
- const char *Result = command->Execute(buffer);
- Skins.Message(mtStatus, NULL);
- if (Result)
- return AddSubMenu(new cMenuText(command->Title(), Result, fontFix));
- return osBack;
- }
- }
- return osContinue;
+ int current = Current();
+ if (current <= 7) {
+ if (current == 0)
+ return AddSubMenu(new cMenuSearchResultsForQuery(event->Title(), true));
+ if (current == 1)
+ return Record();
+ if (current == 2)
+ return Switch();
+ if (current == 3)
+ return CreateSearchTimer();
+ if (current == 4)
+ return AddSubMenu(new cMenuSearchResultsForRecs(event->Title()));
+ if (current == 5)
+ return MarkAsRecorded();
+ if (current == 6)
+ return AddToSwitchList();
+ if (current == 7)
+ return CreateBlacklist();
+ }
+
+ cCommand *command = commands.Get(current - 8);
+ if (command) {
+ cString buffer;
+ bool confirmed = true;
+ if (command->Confirm()) {
+ buffer = cString::sprintf("%s?", command->Title());
+ confirmed = Interface->Confirm(buffer);
+ }
+ if (confirmed) {
+ buffer = cString::sprintf("%s...", command->Title());
+ Skins.Message(mtStatus, buffer);
+
+ {
+ LOCK_CHANNELS_READ;
+ buffer = cString::sprintf("'%s' %ld %ld %d '%s' '%s'",
+ EscapeString(event->Title()).c_str(),
+ event->StartTime(),
+ event->EndTime(),
+ ChannelNrFromEvent(event),
+ EscapeString(Channels->GetByChannelID(event->ChannelID(), true, true)->Name()).c_str(),
+ EscapeString(event->ShortText() ? event->ShortText() : "").c_str());
+ }
+ const char *Result = command->Execute(buffer);
+ Skins.Message(mtStatus, NULL);
+ if (Result)
+ return AddSubMenu(new cMenuText(command->Title(), Result, fontFix));
+ return osBack;
+ }
+ }
+ return osContinue;
}
eOSState cMenuSearchCommands::ProcessKey(eKeys Key)
{
- bool hadSubmenu = HasSubMenu();
- eOSState state = cOsdMenu::ProcessKey(Key);
-
- // jump back to calling menu, if a command was called directly with key '1' .. '9'
- if (directCall && hadSubmenu && !HasSubMenu())
- return osBack;
-
- if (state == osUnknown) {
- switch (Key) {
- case kGreen:
- case kYellow:
- case kBlue:
+ bool hadSubmenu = HasSubMenu();
+ eOSState state = cOsdMenu::ProcessKey(Key);
+
+ // jump back to calling menu, if a command was called directly with key '1' .. '9'
+ if (directCall && hadSubmenu && !HasSubMenu())
+ return osBack;
+
+ if (state == osUnknown) {
+ switch (Key) {
+ case kGreen:
+ case kYellow:
+ case kBlue:
return osContinue;
- case k1...k9:
- case kOk:
+ case k1...k9:
+ case kOk:
return Execute();
- default: break;
- }
- }
- return state;
+ default:
+ break;
+ }
+ }
+ return state;
}
diff --git a/menu_commands.h b/menu_commands.h
index e144e08..5b54b6e 100644
--- a/menu_commands.h
+++ b/menu_commands.h
@@ -29,25 +29,26 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
// --- cMenuSearchCommands ---------------------------------------------------------
-class cMenuSearchCommands : public cOsdMenu {
+class cMenuSearchCommands : public cOsdMenu
+{
private:
- cCommands commands;
- eOSState Execute(void);
- const cEvent* event;
- cSearchExt* search;
- bool directCall;
+ cCommands commands;
+ eOSState Execute(void);
+ const cEvent* event;
+ cSearchExt* search;
+ bool directCall;
public:
- cMenuSearchCommands(const char *Title, const cEvent* Event, bool DirectCall = false, cSearchExt* Search = NULL);
- virtual ~cMenuSearchCommands();
- virtual eOSState ProcessKey(eKeys Key);
- virtual eOSState Record(void);
- virtual eOSState Switch(void);
- virtual eOSState ExtendedSearch(void);
- virtual eOSState CreateSearchTimer(void);
- virtual eOSState MarkAsRecorded(void);
- virtual eOSState AddToSwitchList(void);
- virtual eOSState CreateBlacklist(void);
- void LoadCommands();
+ cMenuSearchCommands(const char *Title, const cEvent* Event, bool DirectCall = false, cSearchExt* Search = NULL);
+ virtual ~cMenuSearchCommands();
+ virtual eOSState ProcessKey(eKeys Key);
+ virtual eOSState Record(void);
+ virtual eOSState Switch(void);
+ virtual eOSState ExtendedSearch(void);
+ virtual eOSState CreateSearchTimer(void);
+ virtual eOSState MarkAsRecorded(void);
+ virtual eOSState AddToSwitchList(void);
+ virtual eOSState CreateBlacklist(void);
+ void LoadCommands();
};
#endif
diff --git a/menu_conflictcheck.c b/menu_conflictcheck.c
index 88d1a0e..3e03cfe 100644
--- a/menu_conflictcheck.c
+++ b/menu_conflictcheck.c
@@ -38,21 +38,18 @@ cMenuConflictCheckItem::cMenuConflictCheckItem(cConflictCheckTime* Ct, cConflict
checktime = Ct;
timerObj = TimerObj;
cString buffer;
- if (!TimerObj) // print header
- {
- struct tm tm_r;
- const time_t t = checktime->evaltime;
- tm *tm = localtime_r(&t, &tm_r);
- char dateshort[7] = "";
- strftime(dateshort, sizeof(dateshort), "%d.%m.", tm);
- buffer = cString::sprintf("%s\t%s %s", WEEKDAYNAME(t), dateshort, TIMESTRING(t));
- SetSelectable(false);
- }
- else
- {
- const cTimer* t = timerObj->timer;
- int recPart = timerObj->recDuration * 100 / (timerObj->stop - timerObj->start);
- buffer = cString::sprintf("%d\t%s\t%d\t%2d%%\t%s", t->Channel()->Number(), t->Channel()->ShortName(true), t->Priority(), recPart, t->File());
+ if (!TimerObj) { // print header
+ struct tm tm_r;
+ const time_t t = checktime->evaltime;
+ tm *tm = localtime_r(&t, &tm_r);
+ char dateshort[7] = "";
+ strftime(dateshort, sizeof(dateshort), "%d.%m.", tm);
+ buffer = cString::sprintf("%s\t%s %s", WEEKDAYNAME(t), dateshort, TIMESTRING(t));
+ SetSelectable(false);
+ } else {
+ const cTimer* t = timerObj->timer;
+ int recPart = timerObj->recDuration * 100 / (timerObj->stop - timerObj->start);
+ buffer = cString::sprintf("%d\t%s\t%d\t%2d%%\t%s", t->Channel()->Number(), t->Channel()->ShortName(true), t->Priority(), recPart, t->File());
}
SetText(buffer);
}
@@ -60,9 +57,9 @@ cMenuConflictCheckItem::cMenuConflictCheckItem(cConflictCheckTime* Ct, cConflict
// --- cMenuConflictCheck -------------------------------------------------------
cMenuConflictCheck::cMenuConflictCheck()
-:cOsdMenu("", 4, 12, 4, 5, 30)
+ : cOsdMenu("", 4, 12, 4, 5, 30)
{
- SetMenuCategory(mcTimerEdit);
+ SetMenuCategory(mcTimerEdit);
showAll = false;
lastSel = -1;
BuildList();
@@ -71,22 +68,20 @@ cMenuConflictCheck::cMenuConflictCheck()
void cMenuConflictCheck::Update()
{
- if (conflictCheck.numConflicts > 0)
- {
- if (conflictCheck.numConflicts==conflictCheck.relevantConflicts)
- SetHelp(conflictCheck.relevantConflicts?tr("Button$Details"):NULL, NULL, NULL, NULL);
- else if (showAll)
- SetHelp(tr("Button$Details"), NULL, NULL, tr("Button$Filter"));
- else
- SetHelp(conflictCheck.relevantConflicts?tr("Button$Details"):NULL, NULL, NULL, tr("Button$Show all"));
- }
- else
- SetHelp(NULL, NULL, NULL, NULL);
+ if (conflictCheck.numConflicts > 0) {
+ if (conflictCheck.numConflicts == conflictCheck.relevantConflicts)
+ SetHelp(conflictCheck.relevantConflicts ? tr("Button$Details") : NULL, NULL, NULL, NULL);
+ else if (showAll)
+ SetHelp(tr("Button$Details"), NULL, NULL, tr("Button$Filter"));
+ else
+ SetHelp(conflictCheck.relevantConflicts ? tr("Button$Details") : NULL, NULL, NULL, tr("Button$Show all"));
+ } else
+ SetHelp(NULL, NULL, NULL, NULL);
cString buffer = cString::sprintf("%s - %d/%d %s", tr("Timer conflicts"),
- showAll?conflictCheck.numConflicts:conflictCheck.relevantConflicts,
- conflictCheck.numConflicts,
- tr("conflicts"));
+ showAll ? conflictCheck.numConflicts : conflictCheck.relevantConflicts,
+ conflictCheck.numConflicts,
+ tr("conflicts"));
SetTitle(buffer);
Display();
}
@@ -97,24 +92,20 @@ bool cMenuConflictCheck::BuildList()
conflictCheck.Check();
if ((showAll && conflictCheck.numConflicts > 0) ||
- conflictCheck.relevantConflicts > 0)
- {
- cList<cConflictCheckTime>* failedList = conflictCheck.GetFailed();
- for(cConflictCheckTime* ct = failedList->First(); ct; ct = failedList->Next(ct))
- {
- if (!showAll && ct->ignore) continue;
- Add(new cMenuConflictCheckItem(ct));
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it;
- for (it = ct->failedTimers.begin(); it != ct->failedTimers.end(); ++it)
- if (!(*it)->ignore || showAll)
- Add(new cMenuConflictCheckItem(ct, *it));
- }
- }
- else
- {
- cOsdItem* pInfoItem = new cOsdItem(conflictCheck.numConflicts==0?tr("no conflicts!"):tr("no important conflicts!"));
- pInfoItem->SetSelectable(false);
- Add(pInfoItem);
+ conflictCheck.relevantConflicts > 0) {
+ cList<cConflictCheckTime>* failedList = conflictCheck.GetFailed();
+ for (cConflictCheckTime* ct = failedList->First(); ct; ct = failedList->Next(ct)) {
+ if (!showAll && ct->ignore) continue;
+ Add(new cMenuConflictCheckItem(ct));
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it;
+ for (it = ct->failedTimers.begin(); it != ct->failedTimers.end(); ++it)
+ if (!(*it)->ignore || showAll)
+ Add(new cMenuConflictCheckItem(ct, *it));
+ }
+ } else {
+ cOsdItem* pInfoItem = new cOsdItem(conflictCheck.numConflicts == 0 ? tr("no conflicts!") : tr("no important conflicts!"));
+ pInfoItem->SetSelectable(false);
+ Add(pInfoItem);
}
SetCurrent(Get(lastSel));
return false;
@@ -123,38 +114,36 @@ bool cMenuConflictCheck::BuildList()
cConflictCheckTimerObj* cMenuConflictCheck::CurrentTimerObj(void)
{
cMenuConflictCheckItem *item = (cMenuConflictCheckItem *)Get(Current());
- return (item && item->Selectable())? item->timerObj : NULL;
+ return (item && item->Selectable()) ? item->timerObj : NULL;
}
eOSState cMenuConflictCheck::ProcessKey(eKeys Key)
{
bool HadSubMenu = HasSubMenu();
eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown)
- {
- switch (Key)
- {
- case kOk:
- if (Count() == 1)
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk:
+ if (Count() == 1)
return osBack;
- case kRed:
- if (CurrentTimerObj())
+ case kRed:
+ if (CurrentTimerObj())
state = AddSubMenu(new cMenuConflictCheckDetails(CurrentTimerObj(), &conflictCheck));
- break;
- case kBlue:
- showAll = !showAll;
- BuildList();
- Update();
- state = osContinue;
- break;
- default: break;
- }
+ break;
+ case kBlue:
+ showAll = !showAll;
+ BuildList();
+ Update();
+ state = osContinue;
+ break;
+ default:
+ break;
+ }
}
- if (HadSubMenu && !HasSubMenu()) // Update conflict list
- {
- lastSel = Current();
- BuildList();
- Update();
+ if (HadSubMenu && !HasSubMenu()) { // Update conflict list
+ lastSel = Current();
+ BuildList();
+ Update();
}
return state;
}
@@ -164,7 +153,7 @@ cMenuConflictCheckDetailsItem::cMenuConflictCheckDetailsItem(cConflictCheckTimer
{
timerObj = TimerObj;
LOCK_TIMERS_READ;
- hasTimer = timerObj->OrigTimer(Timers)?timerObj->OrigTimer(Timers)->HasFlags(tfActive):false;
+ hasTimer = timerObj->OrigTimer(Timers) ? timerObj->OrigTimer(Timers)->HasFlags(tfActive) : false;
Update(true);
}
@@ -172,28 +161,25 @@ bool cMenuConflictCheckDetailsItem::Update(bool Force)
{
bool oldhasTimer = hasTimer;
LOCK_TIMERS_READ;
- hasTimer = timerObj->OrigTimer(Timers)?timerObj->OrigTimer(Timers)->HasFlags(tfActive):false;
- if (Force || hasTimer != oldhasTimer)
- {
- const cTimer* timer = timerObj->timer;
- char device[2]="";
- if (hasTimer)
- {
- if (!timerObj->conflCheckTime && timerObj->device > -1)
- sprintf(device, "%d", timerObj->device+1);
- else
- {
- if (timer->Local())
- strcpy(device, tr("C"));
- else
- strcpy(device, "R"); //Remote Timer
- }
- }
-
-// cString buffer = cString::sprintf("%s\t%s\t%d\t%s - %s\t%d\t%s\t%s", hasTimer?">":"", timer->Remote()?timer->Remote():"", timer->Channel()->Number(), TIMESTRING(timerObj->start), TIMESTRING(timerObj->stop), timer->Priority(), device, timer->File());
- cString buffer = cString::sprintf("%s\t%d\t%s - %s\t%d\t%s\t%s", hasTimer?">":"", timer->Channel()->Number(), TIMESTRING(timerObj->start), TIMESTRING(timerObj->stop), timer->Priority(), device, timer->File());
-
- SetText(buffer);
+ hasTimer = timerObj->OrigTimer(Timers) ? timerObj->OrigTimer(Timers)->HasFlags(tfActive) : false;
+ if (Force || hasTimer != oldhasTimer) {
+ const cTimer* timer = timerObj->timer;
+ char device[2] = "";
+ if (hasTimer) {
+ if (!timerObj->conflCheckTime && timerObj->device > -1)
+ sprintf(device, "%d", timerObj->device + 1);
+ else {
+ if (timer->Local())
+ strcpy(device, tr("C"));
+ else
+ strcpy(device, "R"); //Remote Timer
+ }
+ }
+
+// cString buffer = cString::sprintf("%s\t%s\t%d\t%s - %s\t%d\t%s\t%s", hasTimer?">":"", timer->Remote()?timer->Remote():"", timer->Channel()->Number(), TIMESTRING(timerObj->start), TIMESTRING(timerObj->stop), timer->Priority(), device, timer->File());
+ cString buffer = cString::sprintf("%s\t%d\t%s - %s\t%d\t%s\t%s", hasTimer ? ">" : "", timer->Channel()->Number(), TIMESTRING(timerObj->start), TIMESTRING(timerObj->stop), timer->Priority(), device, timer->File());
+
+ SetText(buffer);
}
return true;
}
@@ -201,15 +187,15 @@ bool cMenuConflictCheckDetailsItem::Update(bool Force)
// --- cMenuConflictCheckDetails -------------------------------------------------------
cMenuConflictCheckDetails::cMenuConflictCheckDetails(cConflictCheckTimerObj* TimerObj, cConflictCheck* ConflictCheck)
-:cOsdMenu(tr("Timer conflicts"), 2, 4, 13, 3, 2)
+ : cOsdMenu(tr("Timer conflicts"), 2, 4, 13, 3, 2)
{
- SetMenuCategory(mcTimerEdit);
+ SetMenuCategory(mcTimerEdit);
timerObj = TimerObj;
checktime = timerObj->conflCheckTime;
conflictCheck = ConflictCheck;
BuildList();
SetHelpKeys();
-
+
int recPart = timerObj->recDuration * 100 / (timerObj->stop - timerObj->start);
cString buffer = cString::sprintf("%s - %s - %d%%", DATESTRING(checktime->evaltime), TIMESTRING(checktime->evaltime), recPart);
SetTitle(buffer);
@@ -220,15 +206,14 @@ bool cMenuConflictCheckDetails::BuildList()
Clear();
int sel = -1;
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it;
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it;
if (timerObj->concurrentTimers)
- for (it = timerObj->concurrentTimers->begin(); it != timerObj->concurrentTimers->end(); ++it)
- {
- Add(new cMenuConflictCheckDetailsItem(*it));
- if ((*it)->Event())
- eventObjects.Add((*it)->Event());
- if ((*it) == timerObj) sel = Count()-1;
- }
+ for (it = timerObj->concurrentTimers->begin(); it != timerObj->concurrentTimers->end(); ++it) {
+ Add(new cMenuConflictCheckDetailsItem(*it));
+ if ((*it)->Event())
+ eventObjects.Add((*it)->Event());
+ if ((*it) == timerObj) sel = Count() - 1;
+ }
SetCurrent(Get(sel));
return true;
}
@@ -238,12 +223,11 @@ void cMenuConflictCheckDetails::SetHelpKeys()
cConflictCheckTimerObj* curTimerObj = CurrentTimerObj();
bool hasTimer = true;
bool hasEvent = false;
- if (curTimerObj)
- {
- hasTimer = curTimerObj->timer->HasFlags(tfActive);
+ if (curTimerObj) {
+ hasTimer = curTimerObj->timer->HasFlags(tfActive);
hasEvent = curTimerObj->Event();
}
- SetHelp(hasEvent?tr("Button$Repeats"):NULL, trVDR("Button$On/Off"), hasTimer?trVDR("Button$Delete"):NULL, tr("Button$Commands"));
+ SetHelp(hasEvent ? tr("Button$Repeats") : NULL, trVDR("Button$On/Off"), hasTimer ? trVDR("Button$Delete") : NULL, tr("Button$Commands"));
}
cConflictCheckTimerObj* cMenuConflictCheckDetails::CurrentTimerObj(void)
@@ -255,14 +239,13 @@ cConflictCheckTimerObj* cMenuConflictCheckDetails::CurrentTimerObj(void)
eOSState cMenuConflictCheckDetails::Commands(eKeys Key)
{
if (HasSubMenu() || Count() == 0)
- return osContinue;
+ return osContinue;
cConflictCheckTimerObj* curTimerObj = CurrentTimerObj();
- if (curTimerObj && curTimerObj->Event())
- {
+ if (curTimerObj && curTimerObj->Event()) {
cMenuSearchCommands *menu;
eOSState state = AddSubMenu(menu = new cMenuSearchCommands(tr("EPG Commands"), curTimerObj->Event(), true));
if (Key != kNone)
- state = menu->ProcessKey(Key);
+ state = menu->ProcessKey(Key);
return state;
}
return osContinue;
@@ -270,56 +253,54 @@ eOSState cMenuConflictCheckDetails::Commands(eKeys Key)
eOSState cMenuConflictCheckDetails::ToggleTimer(cConflictCheckTimerObj* TimerObj)
{
- LOCK_TIMERS_WRITE;
- Timers->SetExplicitModify();
- if (!TimerObj || !TimerObj->OrigTimer(Timers)) return osContinue;
- TimerObj->OrigTimer(Timers)->OnOff(); // Toggles Timer Flag
- Timers->SetModified();
- Update();
- Display();
- return osContinue;
+ LOCK_TIMERS_WRITE;
+ Timers->SetExplicitModify();
+ if (!TimerObj || !TimerObj->OrigTimer(Timers)) return osContinue;
+ TimerObj->OrigTimer(Timers)->OnOff(); // Toggles Timer Flag
+ Timers->SetModified();
+ Update();
+ Display();
+ return osContinue;
}
bool cMenuConflictCheckDetails::Update(bool Force)
{
bool result = false;
for (cOsdItem *item = First(); item; item = Next(item)) {
- if (item->Selectable() && ((cMenuConflictCheckDetailsItem *)item)->Update(Force))
- result = true;
+ if (item->Selectable() && ((cMenuConflictCheckDetailsItem *)item)->Update(Force))
+ result = true;
}
return result;
}
eOSState cMenuConflictCheckDetails::DeleteTimer(cConflictCheckTimerObj* TimerObj)
{
- LOCK_TIMERS_WRITE;
- Timers->SetExplicitModify();
- cTimer* timer = TimerObj->OrigTimer(Timers);
- // Check if this timer is active:
- if (timer) {
- if (Interface->Confirm(trVDR("Delete timer?"))) {
- if (timer->Recording()) {
- if (Interface->Confirm(trVDR("Timer still recording - really delete?"))) {
- timer->Skip();
- cRecordControls::Process(Timers, time(NULL));
- }
- else
- return osContinue;
- }
- if (!HandleRemoteTimerModifications(NULL,timer))
- {
- LogFile.Log(2,"HandleRemoteTimerModifications failed");
- return osContinue;
- }
- LogFile.iSysLog("deleting timer %s", *timer->ToDescr());
- Timers->Del(timer);
- cOsdMenu::Del(Current());
- Timers->SetModified();
- Display();
- return osBack;
+ LOCK_TIMERS_WRITE;
+ Timers->SetExplicitModify();
+ cTimer* timer = TimerObj->OrigTimer(Timers);
+ // Check if this timer is active:
+ if (timer) {
+ if (Interface->Confirm(trVDR("Delete timer?"))) {
+ if (timer->Recording()) {
+ if (Interface->Confirm(trVDR("Timer still recording - really delete?"))) {
+ timer->Skip();
+ cRecordControls::Process(Timers, time(NULL));
+ } else
+ return osContinue;
+ }
+ if (!HandleRemoteTimerModifications(NULL, timer)) {
+ LogFile.Log(2, "HandleRemoteTimerModifications failed");
+ return osContinue;
+ }
+ LogFile.iSysLog("deleting timer %s", *timer->ToDescr());
+ Timers->Del(timer);
+ cOsdMenu::Del(Current());
+ Timers->SetModified();
+ Display();
+ return osBack;
+ }
}
- }
- return osContinue;
+ return osContinue;
}
@@ -327,34 +308,32 @@ eOSState cMenuConflictCheckDetails::ShowSummary()
{
cConflictCheckTimerObj* curTimerObj = CurrentTimerObj();
if (!curTimerObj)
- return osContinue;
+ return osContinue;
const cEvent *ei = curTimerObj->Event();
- if (ei)
- {
- const cChannel *channel;
- {
- LOCK_CHANNELS_READ;
- channel = Channels->GetByChannelID(ei->ChannelID(), true, true);
- }
- if (channel)
- return AddSubMenu(new cMenuEventSearchSimple(ei, eventObjects));
+ if (ei) {
+ const cChannel *channel;
+ {
+ LOCK_CHANNELS_READ;
+ channel = Channels->GetByChannelID(ei->ChannelID(), true, true);
+ }
+ if (channel)
+ return AddSubMenu(new cMenuEventSearchSimple(ei, eventObjects));
}
return osContinue;
}
void cMenuConflictCheckDetails::UpdateCurrent()
{
- cEventObj* cureventObj = eventObjects.GetCurrent();
- if (cureventObj && cureventObj->Event())
- for (cMenuConflictCheckDetailsItem *item = (cMenuConflictCheckDetailsItem *)First(); item; item = (cMenuConflictCheckDetailsItem *)Next(item))
- if (item->Selectable() && item->timerObj && item->timerObj->Event() == cureventObj->Event())
- {
- cureventObj->Select(false);
- SetCurrent(item);
- Display();
- break;
- }
+ cEventObj* cureventObj = eventObjects.GetCurrent();
+ if (cureventObj && cureventObj->Event())
+ for (cMenuConflictCheckDetailsItem *item = (cMenuConflictCheckDetailsItem *)First(); item; item = (cMenuConflictCheckDetailsItem *)Next(item))
+ if (item->Selectable() && item->timerObj && item->timerObj->Event() == cureventObj->Event()) {
+ cureventObj->Select(false);
+ SetCurrent(item);
+ Display();
+ break;
+ }
}
eOSState cMenuConflictCheckDetails::ProcessKey(eKeys Key)
@@ -363,114 +342,96 @@ eOSState cMenuConflictCheckDetails::ProcessKey(eKeys Key)
eOSState state = cOsdMenu::ProcessKey(Key);
if (!HasSubMenu() && HadSubMenu) // navigation in summary could have changed current item, so update it
- UpdateCurrent();
-
- if (state == osUnknown)
- {
- switch (Key)
- {
- case k1...k9:
- if (!HasSubMenu())
- return Commands(Key);
- else
- state = osContinue;
- break;
- case kOk:
- if (!HasSubMenu())
- return ShowSummary();
- else
- state = osContinue;
- break;
- case kRed:
- if(!HasSubMenu())
- {
- if (CurrentTimerObj() && CurrentTimerObj()->Event())
- return Commands(k1);
- else
- state = osContinue;
- }
- else
- state = osContinue;
- break;
- case kGreen:
- if(!HasSubMenu())
- state = ToggleTimer(CurrentTimerObj());
- break;
- case kYellow:
- if(!HasSubMenu())
- state = DeleteTimer(CurrentTimerObj());
- break;
- case kBlue:
- if(!HasSubMenu())
- {
- if (CurrentTimerObj() && CurrentTimerObj()->Event())
- return AddSubMenu(new cMenuSearchCommands(tr("EPG Commands"),CurrentTimerObj()->Event()));
- else
- state = osContinue;
+ UpdateCurrent();
+
+ if (state == osUnknown) {
+ switch (Key) {
+ case k1...k9:
+ if (!HasSubMenu())
+ return Commands(Key);
+ else
+ state = osContinue;
+ break;
+ case kOk:
+ if (!HasSubMenu())
+ return ShowSummary();
+ else
+ state = osContinue;
+ break;
+ case kRed:
+ if (!HasSubMenu()) {
+ if (CurrentTimerObj() && CurrentTimerObj()->Event())
+ return Commands(k1);
+ else
+ state = osContinue;
+ } else
+ state = osContinue;
+ break;
+ case kGreen:
+ if (!HasSubMenu())
+ state = ToggleTimer(CurrentTimerObj());
+ break;
+ case kYellow:
+ if (!HasSubMenu())
+ state = DeleteTimer(CurrentTimerObj());
+ break;
+ case kBlue:
+ if (!HasSubMenu()) {
+ if (CurrentTimerObj() && CurrentTimerObj()->Event())
+ return AddSubMenu(new cMenuSearchCommands(tr("EPG Commands"), CurrentTimerObj()->Event()));
+ else
+ state = osContinue;
+ } else
+ state = osContinue;
+ break;
+ default:
+ break;
}
- else
- state = osContinue;
- break;
- default: break;
- }
}
- if (!HasSubMenu())
- {
- // perhaps a timer was deleted, so first check this
- if (conflictCheck)
- {
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it;
- if (timerObj->concurrentTimers)
- {
- for (it = timerObj->concurrentTimers->begin(); it != timerObj->concurrentTimers->end(); ++it)
- {
- bool found = false;
- LOCK_TIMERS_READ;
- for(const cTimer* checkT = Timers->First(); checkT; checkT = Timers->Next(checkT))
- {
- checkT->Matches();
- if (checkT == (*it)->OrigTimer(Timers)) // ok -> found, check for changes
- {
- if (checkT->IsSingleEvent())
- {
- if (checkT->StartTime() == (*it)->start && checkT->StopTime() == (*it)->stop)
- {
- found = true;
- break;
- }
- }
- else // repeating timer
- {
- if (checkT->DayMatches((*it)->start)) // same day?
- {
- int begin = cTimer::TimeToInt(checkT->Start()); // seconds from midnight
- int length = cTimer::TimeToInt(checkT->Stop()) - begin;
- if (length < 0)
- length += SECSINDAY;
-
- time_t Start = cTimer::SetTime((*it)->start, cTimer::TimeToInt(checkT->Start()));
- if (Start == (*it)->start && (*it)->stop == (*it)->start + length)
- found = true;
- }
- }
- }
- }
- if (!found) return osBack;
- }
- }
- }
-
- if (Key != kNone)
- SetHelpKeys();
- if ((HadSubMenu || gl_TimerProgged) && Update(true))
- {
- if (gl_TimerProgged) // when using epgsearch's timer edit menu, update is delayed because of SVDRP
- {
- gl_TimerProgged = 0;
- SetHelpKeys();
- }
- Display();
- }
+ if (!HasSubMenu()) {
+ // perhaps a timer was deleted, so first check this
+ if (conflictCheck) {
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it;
+ if (timerObj->concurrentTimers) {
+ for (it = timerObj->concurrentTimers->begin(); it != timerObj->concurrentTimers->end(); ++it) {
+ bool found = false;
+ LOCK_TIMERS_READ;
+ for (const cTimer* checkT = Timers->First(); checkT; checkT = Timers->Next(checkT)) {
+ checkT->Matches();
+ if (checkT == (*it)->OrigTimer(Timers)) { // ok -> found, check for changes
+ if (checkT->IsSingleEvent()) {
+ if (checkT->StartTime() == (*it)->start && checkT->StopTime() == (*it)->stop) {
+ found = true;
+ break;
+ }
+ } else { // repeating timer
+ if (checkT->DayMatches((*it)->start)) { // same day?
+ int begin = cTimer::TimeToInt(checkT->Start()); // seconds from midnight
+ int length = cTimer::TimeToInt(checkT->Stop()) - begin;
+ if (length < 0)
+ length += SECSINDAY;
+
+ time_t Start = cTimer::SetTime((*it)->start, cTimer::TimeToInt(checkT->Start()));
+ if (Start == (*it)->start && (*it)->stop == (*it)->start + length)
+ found = true;
+ }
+ }
+ }
+ }
+ if (!found) return osBack;
+ }
+ }
+ }
+
+ if (Key != kNone)
+ SetHelpKeys();
+ if ((HadSubMenu || gl_TimerProgged) && Update(true)) {
+ if (gl_TimerProgged) { // when using epgsearch's timer edit menu, update is delayed because of SVDRP
+ gl_TimerProgged = 0;
+ SetHelpKeys();
+ }
+ Display();
+ }
}
return state;
}
diff --git a/menu_conflictcheck.h b/menu_conflictcheck.h
index e8d48d0..e5e357a 100644
--- a/menu_conflictcheck.h
+++ b/menu_conflictcheck.h
@@ -29,7 +29,8 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "menu_event.h"
// --- cMenuConflictCheckItem ------------------------------------------------------
-class cMenuConflictCheckItem : public cOsdItem {
+class cMenuConflictCheckItem : public cOsdItem
+{
public:
cConflictCheckTime* checktime;
cConflictCheckTimerObj* timerObj;
@@ -37,7 +38,8 @@ public:
};
// --- cMenuConflictCheck ------------------------------------------------------
-class cMenuConflictCheck : public cOsdMenu {
+class cMenuConflictCheck : public cOsdMenu
+{
private:
cConflictCheck conflictCheck;
bool showAll;
@@ -46,12 +48,13 @@ private:
cConflictCheckTimerObj* CurrentTimerObj(void);
void Update();
bool BuildList();
- public:
+public:
cMenuConflictCheck();
};
// --- cMenuConflictCheckDetailsItem ------------------------------------------------------
-class cMenuConflictCheckDetailsItem : public cOsdItem {
+class cMenuConflictCheckDetailsItem : public cOsdItem
+{
bool hasTimer;
public:
cConflictCheckTimerObj* timerObj;
@@ -60,7 +63,8 @@ public:
};
// --- cMenuConflictCheckDetails ------------------------------------------------------
-class cMenuConflictCheckDetails : public cOsdMenu {
+class cMenuConflictCheckDetails : public cOsdMenu
+{
private:
cConflictCheck* conflictCheck;
cConflictCheckTimerObj* timerObj;
@@ -77,7 +81,7 @@ private:
bool BuildList();
eOSState ShowSummary();
void UpdateCurrent();
- public:
+public:
cMenuConflictCheckDetails(cConflictCheckTimerObj* TimerObj = NULL, cConflictCheck* ConflictCheck = NULL);
};
diff --git a/menu_deftimercheckmethod.c b/menu_deftimercheckmethod.c
index ce37dd5..4156e75 100644
--- a/menu_deftimercheckmethod.c
+++ b/menu_deftimercheckmethod.c
@@ -48,32 +48,33 @@ bool cDefTimerCheckMode::Parse(const char *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: channelID = tChannelID::FromString(value);
- break;
- case 2: mode = atol(value);
- break;
- default:
- break;
- } //switch
- }
- parameter++;
- }
- if (*pos) 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:
+ channelID = tChannelID::FromString(value);
+ break;
+ case 2:
+ mode = atol(value);
+ break;
+ default:
+ break;
+ } //switch
+ }
+ parameter++;
+ }
+ if (*pos) pos++;
} //while
free(line);
@@ -82,8 +83,8 @@ bool cDefTimerCheckMode::Parse(const char *s)
cString cDefTimerCheckMode::ToText(void) const
{
- cString buffer = cString::sprintf("%s|%d", *channelID.ToString(), mode);
- return buffer;
+ cString buffer = cString::sprintf("%s|%d", *channelID.ToString(), mode);
+ return buffer;
}
bool cDefTimerCheckMode::Save(FILE *f)
@@ -97,8 +98,8 @@ int cDefTimerCheckModes::GetMode(const cChannel* channel)
if (!channel) return 0;
tChannelID ChannelID = channel->GetChannelID();
for (cDefTimerCheckMode *defMode = First(); defMode; defMode = Next(defMode))
- if (defMode->channelID == ChannelID)
- return defMode->mode;
+ if (defMode->channelID == ChannelID)
+ return defMode->mode;
return 0;
}
@@ -107,20 +108,19 @@ void cDefTimerCheckModes::SetMode(const cChannel* channel, int mode)
if (!channel) return;
tChannelID ChannelID = channel->GetChannelID();
for (cDefTimerCheckMode *defMode = First(); defMode; defMode = Next(defMode))
- if (defMode->channelID == ChannelID)
- {
- defMode->mode = mode;
- return;
- }
+ if (defMode->channelID == ChannelID) {
+ defMode->mode = mode;
+ return;
+ }
Add(new cDefTimerCheckMode(ChannelID, mode));
}
// --- cMenuDefTimerCheckMethod ---------------------------------------------------------
cMenuDefTimerCheckMethod::cMenuDefTimerCheckMethod()
-:cOsdMenu(tr("Default timer check method"), 20)
+ : cOsdMenu(tr("Default timer check method"), 20)
{
- SetMenuCategory(mcSetupPlugins);
+ SetMenuCategory(mcSetupPlugins);
CheckModes[0] = tr("no check");
CheckModes[UPD_CHDUR] = tr("by channel and time");
CheckModes[UPD_EVENTID] = tr("by event ID");
@@ -142,14 +142,12 @@ void cMenuDefTimerCheckMethod::Set()
delete modes;
LOCK_CHANNELS_READ;
modes = new int[Channels->Count()];
- int i=0;
- for (const cChannel *channel = Channels->First(); channel; channel = Channels->Next(channel), i++)
- {
- if (!channel->GroupSep() && *channel->Name())
- {
- modes[i] = DefTimerCheckModes.GetMode(channel);
- Add(new cMenuEditStraItem(channel->Name(), &modes[i], 3, CheckModes));
- }
+ int i = 0;
+ for (const cChannel *channel = Channels->First(); channel; channel = Channels->Next(channel), i++) {
+ if (!channel->GroupSep() && *channel->Name()) {
+ modes[i] = DefTimerCheckModes.GetMode(channel);
+ Add(new cMenuEditStraItem(channel->Name(), &modes[i], 3, CheckModes));
+ }
}
SetCurrent(Get(current));
}
@@ -159,19 +157,19 @@ eOSState cMenuDefTimerCheckMethod::ProcessKey(eKeys Key)
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
- switch (Key) {
- case kOk:
- {
- int i=0;
- LOCK_CHANNELS_READ;
- for (const cChannel *channel = Channels->First(); channel; channel = Channels->Next(channel), i++)
- if (!channel->GroupSep() && *channel->Name())
- DefTimerCheckModes.SetMode(channel, modes[i]);
- DefTimerCheckModes.Save();
- return osBack;
- }
- default: break;
- }
+ switch (Key) {
+ case kOk: {
+ int i = 0;
+ LOCK_CHANNELS_READ;
+ for (const cChannel *channel = Channels->First(); channel; channel = Channels->Next(channel), i++)
+ if (!channel->GroupSep() && *channel->Name())
+ DefTimerCheckModes.SetMode(channel, modes[i]);
+ DefTimerCheckModes.Save();
+ return osBack;
+ }
+ default:
+ break;
+ }
}
return state;
}
diff --git a/menu_deftimercheckmethod.h b/menu_deftimercheckmethod.h
index 08f6689..d2545e9 100644
--- a/menu_deftimercheckmethod.h
+++ b/menu_deftimercheckmethod.h
@@ -30,8 +30,9 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#define UPD_CHDUR 1
#define UPD_EVENTID 2
-class cDefTimerCheckMode : public cListObject {
- public:
+class cDefTimerCheckMode : public cListObject
+{
+public:
tChannelID channelID;
int mode;
@@ -42,8 +43,9 @@ class cDefTimerCheckMode : public cListObject {
bool Save(FILE *f);
};
-class cDefTimerCheckModes : public cConfig<cDefTimerCheckMode> {
- public:
+class cDefTimerCheckModes : public cConfig<cDefTimerCheckMode>
+{
+public:
int GetMode(const cChannel* channel);
void SetMode(const cChannel* channel, int mode);
};
@@ -52,9 +54,10 @@ extern cDefTimerCheckModes DefTimerCheckModes;
// --- cMenuDefTimerCheckMethod ---------------------------------------------------------
-class cMenuDefTimerCheckMethod : public cOsdMenu {
+class cMenuDefTimerCheckMethod : public cOsdMenu
+{
int* modes;
- public:
+public:
cMenuDefTimerCheckMethod();
~cMenuDefTimerCheckMethod();
void Set();
diff --git a/menu_dirselect.c b/menu_dirselect.c
index 4f9cfc4..89e22be 100644
--- a/menu_dirselect.c
+++ b/menu_dirselect.c
@@ -34,40 +34,42 @@ cConfDDirExts ConfDDirExts;
// --- cMenuDirItem ---------------------------------------------------------
class cMenuDirItem : public cOsdItem
{
- private:
+private:
char* directory;
- public:
- cMenuDirItem(const char* text) : cOsdItem(text) { directory = strdup(text);}
- ~cMenuDirItem(){ if (directory) free(directory);}
+public:
+ cMenuDirItem(const char* text) : cOsdItem(text) {
+ directory = strdup(text);
+ }
+ ~cMenuDirItem() {
+ if (directory) free(directory);
+ }
virtual int Compare(const cListObject &ListObject) const;
};
int cMenuDirItem::Compare(const cListObject &ListObject) const
{
const cMenuDirItem *p = (cMenuDirItem *)&ListObject;
- int hasVars1 = (strchr(directory,'%') != NULL?1:0);
- int hasVars2 = (strchr(p->directory,'%') != NULL?1:0);
- if (hasVars1 || hasVars2)
- {
- if (hasVars1 != hasVars2)
- return hasVars2-hasVars1;
- else
- return strcasecmp(directory, p->directory);
- }
- else
- return strcasecmp(directory, p->directory);
+ int hasVars1 = (strchr(directory, '%') != NULL ? 1 : 0);
+ int hasVars2 = (strchr(p->directory, '%') != NULL ? 1 : 0);
+ if (hasVars1 || hasVars2) {
+ if (hasVars1 != hasVars2)
+ return hasVars2 - hasVars1;
+ else
+ return strcasecmp(directory, p->directory);
+ } else
+ return strcasecmp(directory, p->directory);
}
// --- cMenuDirSelect ---------------------------------------------------------
cMenuDirSelect::cMenuDirSelect(char* szDirectory)
-:cOsdMenu(tr("Select directory"))
+ : cOsdMenu(tr("Select directory"))
{
- SetMenuCategory(mcTimerEdit);
+ SetMenuCategory(mcTimerEdit);
Directory = szDirectory;
- yellow=NULL;
+ yellow = NULL;
MaxLevel = 1;
CurLevel = 1;
Load();
@@ -82,19 +84,15 @@ int cMenuDirSelect::Level(const char* szDir)
{
int iLevel = 1;
if (strchr(szDir, '%')) // dirs with vars always have level 1
- return 1;
- do
- {
- const char* pos = strchr(szDir, '~');
- if (pos)
- {
- iLevel++;
- szDir = pos+1;
- }
- else
- return iLevel;
- }
- while(true);
+ return 1;
+ do {
+ const char* pos = strchr(szDir, '~');
+ if (pos) {
+ iLevel++;
+ szDir = pos + 1;
+ } else
+ return iLevel;
+ } while (true);
return 1;
}
@@ -104,23 +102,21 @@ void cMenuDirSelect::AddDistinct(const char* szText)
MaxLevel = std::max(MaxLevel, iLevel);
if (iLevel > CurLevel) // only show Items of the specified level, except those with vars
- return;
+ return;
- for(int i=0; i<Count(); i++)
- {
- const char* ItemText = Get(i)->Text();
- char* itemtext = strdup(ItemText);
- char* sztext = strdup(szText);
- ToLower(itemtext);
- ToLower(sztext);
- if (itemtext && strlen(itemtext) > 0 && strcmp(sztext, itemtext) == 0)
- {
- free(itemtext);
- free(sztext);
- return;
- }
- free(itemtext);
- free(sztext);
+ for (int i = 0; i < Count(); i++) {
+ const char* ItemText = Get(i)->Text();
+ char* itemtext = strdup(ItemText);
+ char* sztext = strdup(szText);
+ ToLower(itemtext);
+ ToLower(sztext);
+ if (itemtext && strlen(itemtext) > 0 && strcmp(sztext, itemtext) == 0) {
+ free(itemtext);
+ free(sztext);
+ return;
+ }
+ free(itemtext);
+ free(sztext);
}
Add(new cMenuDirItem(hk(szText)));
}
@@ -130,156 +126,142 @@ void cMenuDirSelect::CreateDirSet(bool extraDirs)
directorySet.clear();
// add distinct directories from current recordings
- {
- LOCK_RECORDINGS_READ;
- for (const cRecording *recording = Recordings->First(); recording; recording = Recordings->Next(recording))
{
- if (recording->HierarchyLevels() > 0)
- {
- char* dir = strdup(recording->Name());
- // strip the trailing rec dir
- char* pos = strrchr(dir, '~');
- if (pos)
- {
- *pos=0;
- for(int iLevel = 0; iLevel < recording->HierarchyLevels(); iLevel++)
- {
- directorySet.insert(dir);
- char* pos = strrchr(dir, '~');
- if (pos)
- *pos=0;
- }
- }
- free(dir);
- }
- }
- } // give up Recordings Lock
+ LOCK_RECORDINGS_READ;
+ for (const cRecording *recording = Recordings->First(); recording; recording = Recordings->Next(recording)) {
+ if (recording->HierarchyLevels() > 0) {
+ char* dir = strdup(recording->Name());
+ // strip the trailing rec dir
+ char* pos = strrchr(dir, '~');
+ if (pos) {
+ *pos = 0;
+ for (int iLevel = 0; iLevel < recording->HierarchyLevels(); iLevel++) {
+ directorySet.insert(dir);
+ char* pos = strrchr(dir, '~');
+ if (pos)
+ *pos = 0;
+ }
+ }
+ free(dir);
+ }
+ }
+ } // give up Recordings Lock
// add distinct directories from current timers
- {
- LOCK_TIMERS_READ;
- for (const cTimer *timer = Timers->First(); timer; timer = Timers->Next(timer))
{
- char* dir = strdup(timer->File());
- // strip the trailing name dir
- char* pos = strrchr(dir, '~');
- if (pos)
- {
- *pos=0;
- do
- {
- directorySet.insert(dir);
- char* pos = strrchr(dir, '~');
- if (pos)
- *pos=0;
- else break;
- }
- while(true);
- }
- free(dir);
+ LOCK_TIMERS_READ;
+ for (const cTimer *timer = Timers->First(); timer; timer = Timers->Next(timer)) {
+ char* dir = strdup(timer->File());
+ // strip the trailing name dir
+ char* pos = strrchr(dir, '~');
+ if (pos) {
+ *pos = 0;
+ do {
+ directorySet.insert(dir);
+ char* pos = strrchr(dir, '~');
+ if (pos)
+ *pos = 0;
+ else break;
+ } while (true);
+ }
+ free(dir);
+ }
}
- }
// add distinct directories from folders.conf
- for(cNestedItem* item = Folders.First(); item; item = Folders.Next(item))
- AddVDRFolders(item);
+ for (cNestedItem* item = Folders.First(); item; item = Folders.Next(item))
+ AddVDRFolders(item);
- if (extraDirs)
- {
- cMutexLock SearchExtsLock(&SearchExts);
- cSearchExt *searchExt = SearchExts.First();
- // add distinct directories from existing search timers
- while (searchExt)
- {
- if (strlen(searchExt->directory) > 0)
- directorySet.insert(searchExt->directory);
- searchExt = SearchExts.Next(searchExt);
- }
- // add distinct directories from epgsearchdirs.conf
- DirExts.Load(AddDirectory(CONFIGDIR, "epgsearchdirs.conf"), true);
- cDirExt* DirExt = DirExts.First();
- while (DirExt)
- {
- directorySet.insert(DirExt->Name());
- DirExt = DirExts.Next(DirExt);
- }
- // add distinct directories from conf.d files
- DirExt = ConfDDirExts.First();
- while (DirExt)
- {
- directorySet.insert(DirExt->Name());
- DirExt = ConfDDirExts.Next(DirExt);
- }
- }
+ if (extraDirs) {
+ cMutexLock SearchExtsLock(&SearchExts);
+ cSearchExt *searchExt = SearchExts.First();
+ // add distinct directories from existing search timers
+ while (searchExt) {
+ if (strlen(searchExt->directory) > 0)
+ directorySet.insert(searchExt->directory);
+ searchExt = SearchExts.Next(searchExt);
+ }
+ // add distinct directories from epgsearchdirs.conf
+ DirExts.Load(AddDirectory(CONFIGDIR, "epgsearchdirs.conf"), true);
+ cDirExt* DirExt = DirExts.First();
+ while (DirExt) {
+ directorySet.insert(DirExt->Name());
+ DirExt = DirExts.Next(DirExt);
+ }
+ // add distinct directories from conf.d files
+ DirExt = ConfDDirExts.First();
+ while (DirExt) {
+ directorySet.insert(DirExt->Name());
+ DirExt = ConfDDirExts.Next(DirExt);
+ }
+ }
}
void cMenuDirSelect::AddVDRFolders(cNestedItem* folder, string parentDirectory)
{
- if (folder == NULL) return;
- string folderDirectory = string((parentDirectory.size() == 0)?"":parentDirectory + "~") + folder->Text();
- directorySet.insert(folderDirectory);
- if (folder->SubItems() == NULL) return;
- for(cNestedItem* subfolder = folder->SubItems()->First(); subfolder; subfolder = folder->SubItems()->Next(subfolder))
- AddVDRFolders(subfolder, folderDirectory);
+ if (folder == NULL) return;
+ string folderDirectory = string((parentDirectory.size() == 0) ? "" : parentDirectory + "~") + folder->Text();
+ directorySet.insert(folderDirectory);
+ if (folder->SubItems() == NULL) return;
+ for (cNestedItem* subfolder = folder->SubItems()->First(); subfolder; subfolder = folder->SubItems()->Next(subfolder))
+ AddVDRFolders(subfolder, folderDirectory);
}
void cMenuDirSelect::Load()
{
int current = Current();
char* oldSelection = NULL; // save old selection for reselection
- if (current>-1)
- oldSelection = strdup(Get(current)->Text());
+ if (current > -1)
+ oldSelection = strdup(Get(current)->Text());
Clear();
CreateDirSet();
std::set<string>::iterator it;
for (it = directorySet.begin(); it != directorySet.end(); ++it)
- AddDistinct((*it).c_str());
+ AddDistinct((*it).c_str());
Sort();
- for(int i=0; i<Count(); i++)
- {
- const char* text = Get(i)->Text();
- if (oldSelection && strchr(text, '%') == NULL && strstr(text, oldSelection) == text) // skip entries with variables
- {
- SetCurrent(Get(i));
- break;
- }
+ for (int i = 0; i < Count(); i++) {
+ const char* text = Get(i)->Text();
+ if (oldSelection && strchr(text, '%') == NULL && strstr(text, oldSelection) == text) { // skip entries with variables
+ SetCurrent(Get(i));
+ break;
+ }
}
if (oldSelection) free(oldSelection);
- if (yellow)
- {
- free(yellow);
- yellow = NULL;
+ if (yellow) {
+ free(yellow);
+ yellow = NULL;
}
- msprintf(&yellow, "%s %d", tr("Button$Level"), (CurLevel==MaxLevel?1:CurLevel+1));
- SetHelp(NULL, NULL, MaxLevel==1?NULL:yellow, tr("Button$Select"));
+ msprintf(&yellow, "%s %d", tr("Button$Level"), (CurLevel == MaxLevel ? 1 : CurLevel + 1));
+ SetHelp(NULL, NULL, MaxLevel == 1 ? NULL : yellow, tr("Button$Select"));
Display();
}
eOSState cMenuDirSelect::ProcessKey(eKeys Key)
{
- eOSState state = cOsdMenu::ProcessKey(Key);
+ eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown) {
- switch ((int)Key) {
- case kBlue|k_Repeat:
- case kYellow:
- if (++CurLevel>MaxLevel)
- CurLevel=1;
- Load();
- return osContinue;
- case kGreen:
- case kRed:
- return osContinue;
- case kBlue:
- case kOk:
- if (Count() > 0)
- strn0cpy(Directory,Get(Current())->Text(), MaxFileName);
- return osBack;
- default: break;
- }
- }
- return state;
+ if (state == osUnknown) {
+ switch ((int)Key) {
+ case kBlue|k_Repeat:
+ case kYellow:
+ if (++CurLevel > MaxLevel)
+ CurLevel = 1;
+ Load();
+ return osContinue;
+ case kGreen:
+ case kRed:
+ return osContinue;
+ case kBlue:
+ case kOk:
+ if (Count() > 0)
+ strn0cpy(Directory, Get(Current())->Text(), MaxFileName);
+ return osBack;
+ default:
+ break;
+ }
+ }
+ return state;
}
diff --git a/menu_dirselect.h b/menu_dirselect.h
index c1d9aa3..902059b 100644
--- a/menu_dirselect.h
+++ b/menu_dirselect.h
@@ -32,13 +32,21 @@ using std::string;
using std::set;
-class cDirExt : public cListObject {
+class cDirExt : public cListObject
+{
private:
char name[MaxFileName];
public:
- cDirExt(void){ name[0]=0; }
- bool Parse(const char *s) {strcpy(name,s); return true;}
- char* Name() {return name;}
+ cDirExt(void) {
+ name[0] = 0;
+ }
+ bool Parse(const char *s) {
+ strcpy(name, s);
+ return true;
+ }
+ char* Name() {
+ return name;
+ }
};
class cDirExts : public cConfig<cDirExt> {};
@@ -49,13 +57,14 @@ extern cConfDDirExts ConfDDirExts;
// --- cMenuDirSelect ---------------------------------------------------------
-class cMenuDirSelect : public cOsdMenu {
+class cMenuDirSelect : public cOsdMenu
+{
private:
int CurLevel;
int MaxLevel;
char* Directory;
char* yellow;
- public:
+public:
static set<string> directorySet;
@@ -68,7 +77,7 @@ private:
int Level(const char* szDir);
void ReplaceDirVars();
- static void CreateDirSet(bool extraDirs=true);
- };
+ static void CreateDirSet(bool extraDirs = true);
+};
#endif
diff --git a/menu_event.c b/menu_event.c
index e94b54a..3463719 100644
--- a/menu_event.c
+++ b/menu_event.c
@@ -30,124 +30,116 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
// --- cMenuEventSearch ------------------------------------------------------------
cMenuEventSearch::cMenuEventSearch(const cEvent* Event, cEventObjects& EventObjects, MenuEventSurfMode SurfMode)
-:cOsdMenu(tr("Event")),
-eventObjects(EventObjects),
-surfMode(SurfMode)
+ : cOsdMenu(tr("Event")),
+ eventObjects(EventObjects),
+ surfMode(SurfMode)
{
- SetMenuCategory(mcEvent);
+ SetMenuCategory(mcEvent);
- eventObjects.SetCurrent(Event);
- szGreen = szYellow = NULL;
- Set();
+ eventObjects.SetCurrent(Event);
+ szGreen = szYellow = NULL;
+ Set();
}
cEventObj* cMenuEventSearch::GetPrev(const cEvent* Event)
{
- cEventObj* prevEventObj = NULL;
- cEventObjects::iterator i;
- for(i = eventObjects.begin(); i != eventObjects.end(); ++i)
- {
- if (*i && (*i)->Event() == Event)
- return prevEventObj;
- else
- prevEventObj = *i;
- }
- return NULL;
+ cEventObj* prevEventObj = NULL;
+ cEventObjects::iterator i;
+ for (i = eventObjects.begin(); i != eventObjects.end(); ++i) {
+ if (*i && (*i)->Event() == Event)
+ return prevEventObj;
+ else
+ prevEventObj = *i;
+ }
+ return NULL;
}
cEventObj* cMenuEventSearch::GetNext(const cEvent* Event)
{
- cEventObjects::iterator i;
- for(i = eventObjects.begin(); i != eventObjects.end(); ++i)
- if (*i && (*i)->Event() == Event)
- {
- cEventObjects::iterator nexti = i;
- ++nexti;
- return nexti != eventObjects.end() ? *nexti : NULL;
- }
-
- return NULL;
+ cEventObjects::iterator i;
+ for (i = eventObjects.begin(); i != eventObjects.end(); ++i)
+ if (*i && (*i)->Event() == Event) {
+ cEventObjects::iterator nexti = i;
+ ++nexti;
+ return nexti != eventObjects.end() ? *nexti : NULL;
+ }
+
+ return NULL;
}
void cMenuEventSearch::Set()
{
- cEventObj* eventObj = eventObjects.GetCurrent();
- if (!eventObj) return;
- event = eventObj->Event();
- if (!event) return;
-
- if (szGreen) free(szGreen);
- if (szYellow) free(szYellow);
- szGreen = szYellow = NULL;
-
- if (event)
- {
- LOCK_TIMERS_READ;
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(event->ChannelID(), true, true);
- bool canSwitch = false;
- if (channel)
- {
- SetTitle(channel->Name());
- canSwitch = channel->Number() != cDevice::CurrentChannel();
- }
-
- cEventObj* eventObjPrev = GetPrev(event);
- cEventObj* eventObjNext = GetNext(event);
-
- eTimerMatch timerMatch = tmNone;
- Timers->GetMatch(event, &timerMatch);
- const char* szRed = trVDR("Button$Record");
- if (timerMatch == tmFull)
- szRed = trVDR("Button$Timer");
-
- if (surfMode == SurfModeUnknown)
- SetHelp(szRed, eventObjPrev ? "<<":NULL, eventObjNext ? ">>":NULL, canSwitch ? trVDR("Button$Switch") : NULL);
- else if (surfMode == SurfModeTime)
- {
- if (eventObjPrev && eventObjPrev->Event()) szGreen = strdup(GETTIMESTRING(eventObjPrev->Event()));
- if (eventObjNext && eventObjNext->Event()) szYellow = strdup(GETTIMESTRING(eventObjNext->Event()));
- SetHelp(szRed, szGreen, szYellow, canSwitch ? trVDR("Button$Switch") : NULL);
- }
- else if (surfMode == SurfModeChannel)
- {
- if (eventObjPrev && eventObjPrev->Event())
- szGreen = strdup(CHANNELNAME(Channels->GetByChannelID(eventObjPrev->Event()->ChannelID(), true, true)));
- if (eventObjNext && eventObjNext->Event())
- szYellow = strdup(CHANNELNAME(Channels->GetByChannelID(eventObjNext->Event()->ChannelID(), true, true)));
- SetHelp(szRed, szGreen, szYellow, canSwitch ? trVDR("Button$Switch") : NULL);
- }
- }
+ cEventObj* eventObj = eventObjects.GetCurrent();
+ if (!eventObj) return;
+ event = eventObj->Event();
+ if (!event) return;
+
+ if (szGreen) free(szGreen);
+ if (szYellow) free(szYellow);
+ szGreen = szYellow = NULL;
+
+ if (event) {
+ LOCK_TIMERS_READ;
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(event->ChannelID(), true, true);
+ bool canSwitch = false;
+ if (channel) {
+ SetTitle(channel->Name());
+ canSwitch = channel->Number() != cDevice::CurrentChannel();
+ }
+
+ cEventObj* eventObjPrev = GetPrev(event);
+ cEventObj* eventObjNext = GetNext(event);
+
+ eTimerMatch timerMatch = tmNone;
+ Timers->GetMatch(event, &timerMatch);
+ const char* szRed = trVDR("Button$Record");
+ if (timerMatch == tmFull)
+ szRed = trVDR("Button$Timer");
+
+ if (surfMode == SurfModeUnknown)
+ SetHelp(szRed, eventObjPrev ? "<<" : NULL, eventObjNext ? ">>" : NULL, canSwitch ? trVDR("Button$Switch") : NULL);
+ else if (surfMode == SurfModeTime) {
+ if (eventObjPrev && eventObjPrev->Event()) szGreen = strdup(GETTIMESTRING(eventObjPrev->Event()));
+ if (eventObjNext && eventObjNext->Event()) szYellow = strdup(GETTIMESTRING(eventObjNext->Event()));
+ SetHelp(szRed, szGreen, szYellow, canSwitch ? trVDR("Button$Switch") : NULL);
+ } else if (surfMode == SurfModeChannel) {
+ if (eventObjPrev && eventObjPrev->Event())
+ szGreen = strdup(CHANNELNAME(Channels->GetByChannelID(eventObjPrev->Event()->ChannelID(), true, true)));
+ if (eventObjNext && eventObjNext->Event())
+ szYellow = strdup(CHANNELNAME(Channels->GetByChannelID(eventObjNext->Event()->ChannelID(), true, true)));
+ SetHelp(szRed, szGreen, szYellow, canSwitch ? trVDR("Button$Switch") : NULL);
+ }
+ }
}
cMenuEventSearch::~cMenuEventSearch()
{
- if (szGreen) free(szGreen);
- if (szYellow) free(szYellow);
+ if (szGreen) free(szGreen);
+ if (szYellow) free(szYellow);
}
void cMenuEventSearch::Display(void)
{
- cOsdMenu::Display();
+ cOsdMenu::Display();
#ifdef USE_GRAPHTFT
- cStatus::MsgOsdSetEvent(event);
+ cStatus::MsgOsdSetEvent(event);
#endif
- if (event)
- {
- DisplayMenu()->SetEvent(event);
- cStatus::MsgOsdTextItem(event->Description());
- }
+ if (event) {
+ DisplayMenu()->SetEvent(event);
+ cStatus::MsgOsdTextItem(event->Description());
+ }
}
eOSState cMenuEventSearch::Commands(eKeys Key)
{
if (HasSubMenu())
- return osContinue;
+ return osContinue;
if (event) {
cMenuSearchCommands *menu;
eOSState state = AddSubMenu(menu = new cMenuSearchCommands(tr("EPG Commands"), event, true));
if (Key != kNone)
- state = menu->ProcessKey(Key);
+ state = menu->ProcessKey(Key);
return state;
}
return osContinue;
@@ -155,97 +147,94 @@ eOSState cMenuEventSearch::Commands(eKeys Key)
eOSState cMenuEventSearch::ProcessKey(eKeys Key)
{
- if (!HasSubMenu())
- {
- switch ((int)Key) {
- case kUp|k_Repeat:
- case kUp:
- case kDown|k_Repeat:
- case kDown:
- case kLeft|k_Repeat:
- case kLeft:
- case kRight|k_Repeat:
- case kRight:
+ if (!HasSubMenu()) {
+ switch ((int)Key) {
+ case kUp|k_Repeat:
+ case kUp:
+ case kDown|k_Repeat:
+ case kDown:
+ case kLeft|k_Repeat:
+ case kLeft:
+ case kRight|k_Repeat:
+ case kRight:
DisplayMenu()->Scroll(NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft, NORMALKEY(Key) == kLeft || NORMALKEY(Key) == kRight);
cStatus::MsgOsdTextItem(NULL, NORMALKEY(Key) == kUp);
return osContinue;
- case k1...k9:
+ case k1...k9:
if (!HasSubMenu())
- return Commands(Key);
+ return Commands(Key);
else
- return osContinue;
+ return osContinue;
break;
- case kInfo: return osBack;
- default: break;
- }
- }
-
- eOSState state = cOsdMenu::ProcessKey(Key);
-
- if (state == osUnknown) {
- switch (Key) {
- case kOk: return osBack;
- case kGreen:
- case kFastRew:
- {
+ case kInfo:
+ return osBack;
+ default:
+ break;
+ }
+ }
+
+ eOSState state = cOsdMenu::ProcessKey(Key);
+
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk:
+ return osBack;
+ case kGreen:
+ case kFastRew: {
cEventObj* eventObjPrev = GetPrev(event);
- if (eventObjPrev && eventObjPrev->Event())
- {
- eventObjects.SetCurrent(eventObjPrev->Event());
- Set();
- Display();
+ if (eventObjPrev && eventObjPrev->Event()) {
+ eventObjects.SetCurrent(eventObjPrev->Event());
+ Set();
+ Display();
}
state = osContinue;
- }
- break;
- case kFastFwd:
- case kYellow:
- {
+ }
+ break;
+ case kFastFwd:
+ case kYellow: {
cEventObj* eventObjNext = GetNext(event);
- if (eventObjNext && eventObjNext->Event())
- {
- eventObjects.SetCurrent(eventObjNext->Event());
- Set();
- Display();
+ if (eventObjNext && eventObjNext->Event()) {
+ eventObjects.SetCurrent(eventObjNext->Event());
+ Set();
+ Display();
}
state = osContinue;
- }
- break;
- default: break;
- }
- }
- return state;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return state;
}
cMenuEventSearchSimple::cMenuEventSearchSimple(const cEvent* Event, cEventObjects& EventObjects)
- :cMenuEventSearch(Event, EventObjects)
+ : cMenuEventSearch(Event, EventObjects)
{
- Set();
+ Set();
}
void cMenuEventSearchSimple::Set()
{
- cEventObj* eventObj = eventObjects.GetCurrent();
- if (!eventObj) return;
- event = eventObj->Event();
- if (!event) return;
-
- if (szGreen) free(szGreen);
- if (szYellow) free(szYellow);
- szGreen = szYellow = NULL;
-
- if (event)
- {
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(event->ChannelID(), true, true);
- if (channel)
- {
- SetTitle(channel->Name());
- }
-
- cEventObj* eventObjPrev = GetPrev(event);
- cEventObj* eventObjNext = GetNext(event);
- SetHelp(NULL, eventObjPrev ? "<<":NULL, eventObjNext ? ">>":NULL, NULL);
- }
- Display();
+ cEventObj* eventObj = eventObjects.GetCurrent();
+ if (!eventObj) return;
+ event = eventObj->Event();
+ if (!event) return;
+
+ if (szGreen) free(szGreen);
+ if (szYellow) free(szYellow);
+ szGreen = szYellow = NULL;
+
+ if (event) {
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(event->ChannelID(), true, true);
+ if (channel) {
+ SetTitle(channel->Name());
+ }
+
+ cEventObj* eventObjPrev = GetPrev(event);
+ cEventObj* eventObjNext = GetNext(event);
+ SetHelp(NULL, eventObjPrev ? "<<" : NULL, eventObjNext ? ">>" : NULL, NULL);
+ }
+ Display();
}
diff --git a/menu_event.h b/menu_event.h
index 5a3adb0..bf45430 100644
--- a/menu_event.h
+++ b/menu_event.h
@@ -26,8 +26,7 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include <list>
-typedef enum
-{
+typedef enum {
SurfModeUnknown,
SurfModeTime,
SurfModeChannel
@@ -35,84 +34,105 @@ typedef enum
class cEventObj
{
- const cEvent *event;
- bool selected;
- public:
- cEventObj(const cEvent* Event, bool Selected = false) : event(Event), selected(Selected) {}
- const cEvent* Event() { return event; }
- bool Selected() { return selected; }
- void Select(bool Selected) { selected = Selected; }
+ const cEvent *event;
+ bool selected;
+public:
+ cEventObj(const cEvent* Event, bool Selected = false) : event(Event), selected(Selected) {}
+ const cEvent* Event() {
+ return event;
+ }
+ bool Selected() {
+ return selected;
+ }
+ void Select(bool Selected) {
+ selected = Selected;
+ }
};
class cEventObjects
{
public:
- typedef std::list< cEventObj* > EventObjectList;
- typedef EventObjectList::size_type size_type;
- typedef EventObjectList::iterator iterator;
- typedef EventObjectList::const_iterator const_iterator;
-
- cEventObjects() {}
- ~cEventObjects()
- {
- for(EventObjectList::iterator i = m_list.begin(); i != m_list.end(); ++i)
- delete (*i);
- }
-
- size_type size() const { return m_list.size(); }
-
- iterator begin() { return m_list.begin(); }
- const_iterator begin() const { return m_list.begin(); }
- iterator end() { return m_list.end(); }
- const_iterator end() const { return m_list.end(); }
-
- void Add(const cEvent* Event) { m_list.push_back(new cEventObj(Event)); }
- void Clear() { m_list.clear(); }
- void SetCurrent(const cEvent* Event)
- {
- for(EventObjectList::iterator i = m_list.begin(); i != m_list.end(); ++i)
- (*i)->Select((*i)->Event() == Event);
- }
- cEventObj* GetCurrent()
- {
- for(EventObjectList::iterator i = m_list.begin(); i != m_list.end(); ++i)
- if ((*i)->Selected())
+ typedef std::list< cEventObj* > EventObjectList;
+ typedef EventObjectList::size_type size_type;
+ typedef EventObjectList::iterator iterator;
+ typedef EventObjectList::const_iterator const_iterator;
+
+ cEventObjects() {}
+ ~cEventObjects() {
+ for (EventObjectList::iterator i = m_list.begin(); i != m_list.end(); ++i)
+ delete(*i);
+ }
+
+ size_type size() const {
+ return m_list.size();
+ }
+
+ iterator begin() {
+ return m_list.begin();
+ }
+ const_iterator begin() const {
+ return m_list.begin();
+ }
+ iterator end() {
+ return m_list.end();
+ }
+ const_iterator end() const {
+ return m_list.end();
+ }
+
+ void Add(const cEvent* Event) {
+ m_list.push_back(new cEventObj(Event));
+ }
+ void Clear() {
+ m_list.clear();
+ }
+ void SetCurrent(const cEvent* Event) {
+ for (EventObjectList::iterator i = m_list.begin(); i != m_list.end(); ++i)
+ (*i)->Select((*i)->Event() == Event);
+ }
+ cEventObj* GetCurrent() {
+ for (EventObjectList::iterator i = m_list.begin(); i != m_list.end(); ++i)
+ if ((*i)->Selected())
return (*i);
- return NULL;
- }
+ return NULL;
+ }
private:
- EventObjectList m_list;
+ EventObjectList m_list;
};
-class cMenuEventSearch : public cOsdMenu {
+class cMenuEventSearch : public cOsdMenu
+{
protected:
- const cEvent *event;
- char* szGreen;
- char* szYellow;
- cEventObjects& eventObjects;
- MenuEventSurfMode surfMode;
-
- virtual void Set();
- cEventObj* GetPrev(const cEvent* Event);
- cEventObj* GetNext(const cEvent* Event);
-
- virtual void Display(void);
- virtual eOSState ProcessKey(eKeys Key);
- eOSState Commands(eKeys Key);
+ const cEvent *event;
+ char* szGreen;
+ char* szYellow;
+ cEventObjects& eventObjects;
+ MenuEventSurfMode surfMode;
+
+ virtual void Set();
+ cEventObj* GetPrev(const cEvent* Event);
+ cEventObj* GetNext(const cEvent* Event);
+
+ virtual void Display(void);
+ virtual eOSState ProcessKey(eKeys Key);
+ eOSState Commands(eKeys Key);
public:
- cMenuEventSearch(const cEvent* Event, cEventObjects& EventObjects, MenuEventSurfMode SurfMode = SurfModeUnknown);
- ~cMenuEventSearch();
+ cMenuEventSearch(const cEvent* Event, cEventObjects& EventObjects, MenuEventSurfMode SurfMode = SurfModeUnknown);
+ ~cMenuEventSearch();
#ifdef USE_GRAPHTFT
- const char* MenuKind() { return "MenuEvent"; }
+ const char* MenuKind() {
+ return "MenuEvent";
+ }
#endif
};
-class cMenuEventSearchSimple : public cMenuEventSearch {
+class cMenuEventSearchSimple : public cMenuEventSearch
+{
private:
- virtual void Set();
+ virtual void Set();
public:
- cMenuEventSearchSimple(const cEvent* Event, cEventObjects& EventObjects);
+ cMenuEventSearchSimple(const cEvent* Event, cEventObjects& EventObjects);
};
#endif
diff --git a/menu_favorites.c b/menu_favorites.c
index a4115c9..4cb42b5 100644
--- a/menu_favorites.c
+++ b/menu_favorites.c
@@ -32,181 +32,168 @@ extern const char* ButtonBlue[3];
extern int exitToMainMenu;
cMenuFavorites::cMenuFavorites()
- : cMenuSearchResults(cTemplFile::GetTemplateByName("MenuFavorites"))
+ : cMenuSearchResults(cTemplFile::GetTemplateByName("MenuFavorites"))
{
- BuildList();
+ BuildList();
}
#ifdef USE_GRAPHTFT
const char* cMenuFavorites::MenuKind()
{
- return "MenuEpgsFavorites";
+ return "MenuEpgsFavorites";
}
void cMenuFavorites::Display(void)
{
- cOsdMenu::Display();
+ cOsdMenu::Display();
- if (Count() > 0)
- {
- int i = 0;
+ if (Count() > 0) {
+ int i = 0;
- for (cOsdItem *item = First(); item; item = Next(item))
- cStatus::MsgOsdEventItem(!item->Selectable() ? 0 :
- ((cMenuSearchResultsItem*)item)->event,
- item->Text(), i++, Count());
- }
+ for (cOsdItem *item = First(); item; item = Next(item))
+ cStatus::MsgOsdEventItem(!item->Selectable() ? 0 :
+ ((cMenuSearchResultsItem*)item)->event,
+ item->Text(), i++, Count());
+ }
}
#endif /* GRAPHTFT */
bool cMenuFavorites::BuildList()
{
- Clear();
- eventObjects.Clear();
-
- cSearchResults* pCompleteSearchResults = NULL;
- cMutexLock SearchExtsLock(&SearchExts);
- cSearchExt *SearchExt = SearchExts.First();
- int timespan = EPGSearchConfig.FavoritesMenuTimespan*60;
-
- while (SearchExt)
- {
- if (SearchExt->useInFavorites)
- pCompleteSearchResults = SearchExt->Run(modeBlue == showNoPayTV?1:0, false, timespan, pCompleteSearchResults, true);
- SearchExt = SearchExts.Next(SearchExt);
- }
-
- if (pCompleteSearchResults)
- {
- set<const cEvent*> foundEvents;
- pCompleteSearchResults->SortBy(CompareEventTime);
-
- for (cSearchResult* pResultObj = pCompleteSearchResults->First();
- pResultObj;
- pResultObj = pCompleteSearchResults->Next(pResultObj))
- {
- if (foundEvents.find(pResultObj->event) == foundEvents.end())
- {
- foundEvents.insert(pResultObj->event);
- Add(new cMenuSearchResultsItem(pResultObj->event, modeYellow == showEpisode, false, menuTemplate));
- eventObjects.Add(pResultObj->event);
+ Clear();
+ eventObjects.Clear();
+
+ cSearchResults* pCompleteSearchResults = NULL;
+ cMutexLock SearchExtsLock(&SearchExts);
+ cSearchExt *SearchExt = SearchExts.First();
+ int timespan = EPGSearchConfig.FavoritesMenuTimespan * 60;
+
+ while (SearchExt) {
+ if (SearchExt->useInFavorites)
+ pCompleteSearchResults = SearchExt->Run(modeBlue == showNoPayTV ? 1 : 0, false, timespan, pCompleteSearchResults, true);
+ SearchExt = SearchExts.Next(SearchExt);
+ }
+
+ if (pCompleteSearchResults) {
+ set<const cEvent*> foundEvents;
+ pCompleteSearchResults->SortBy(CompareEventTime);
+
+ for (cSearchResult* pResultObj = pCompleteSearchResults->First();
+ pResultObj;
+ pResultObj = pCompleteSearchResults->Next(pResultObj)) {
+ if (foundEvents.find(pResultObj->event) == foundEvents.end()) {
+ foundEvents.insert(pResultObj->event);
+ Add(new cMenuSearchResultsItem(pResultObj->event, modeYellow == showEpisode, false, menuTemplate));
+ eventObjects.Add(pResultObj->event);
+ }
}
- }
- delete pCompleteSearchResults;
- }
- SetHelpKeys();
- cString szTitle = cString::sprintf("%s: %d %s", tr("Favorites"), Count(), tr("Search results"));
- SetTitle(szTitle);
- Display();
-
- return true;
+ delete pCompleteSearchResults;
+ }
+ SetHelpKeys();
+ cString szTitle = cString::sprintf("%s: %d %s", tr("Favorites"), Count(), tr("Search results"));
+ SetTitle(szTitle);
+ Display();
+
+ return true;
}
eOSState cMenuFavorites::OnGreen()
{
- eOSState state = osUnknown;
- if(!HasSubMenu())
- {
- toggleKeys = 0;
- cMenuWhatsOnSearch::currentShowMode = cMenuWhatsOnSearch::GetNextMode();
- return osUnknown;
- }
- return state;
+ eOSState state = osUnknown;
+ if (!HasSubMenu()) {
+ toggleKeys = 0;
+ cMenuWhatsOnSearch::currentShowMode = cMenuWhatsOnSearch::GetNextMode();
+ return osUnknown;
+ }
+ return state;
}
eOSState cMenuFavorites::OnYellow()
{
- eOSState state = osUnknown;
- if(!HasSubMenu())
- {
- cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
- if (item && item->event)
- {
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(item->event->ChannelID(), true, true);
- cMenuWhatsOnSearch::scheduleChannel = channel;
- cMenuWhatsOnSearch::currentShowMode = showNow;
- }
- toggleKeys = 0;
- return osBack;
- }
- return state;
+ eOSState state = osUnknown;
+ if (!HasSubMenu()) {
+ cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
+ if (item && item->event) {
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(item->event->ChannelID(), true, true);
+ cMenuWhatsOnSearch::scheduleChannel = channel;
+ cMenuWhatsOnSearch::currentShowMode = showNow;
+ }
+ toggleKeys = 0;
+ return osBack;
+ }
+ return state;
}
eOSState cMenuFavorites::ProcessKey(eKeys Key)
{
- exitToMainMenu = 0;
- if (!HasSubMenu() && Key == kBack)
- {
- exitToMainMenu = 1;
- return osBack;
- }
-
- eOSState state = cMenuSearchResults::ProcessKey(Key);
- if (state == osUnknown)
- {
- switch (Key) {
- case kRecord:
- case kRed:
+ exitToMainMenu = 0;
+ if (!HasSubMenu() && Key == kBack) {
+ exitToMainMenu = 1;
+ return osBack;
+ }
+
+ eOSState state = cMenuSearchResults::ProcessKey(Key);
+ if (state == osUnknown) {
+ switch (Key) {
+ case kRecord:
+ case kRed:
state = OnRed();
break;
- case k0:
- if(!HasSubMenu())
- {
- toggleKeys = 1 - toggleKeys;
- SetHelpKeys(true);
+ case k0:
+ if (!HasSubMenu()) {
+ toggleKeys = 1 - toggleKeys;
+ SetHelpKeys(true);
}
state = osContinue;
break;
- case k1...k9:
- state = HasSubMenu()?osContinue:Commands(Key);
+ case k1...k9:
+ state = HasSubMenu() ? osContinue : Commands(Key);
break;
- case kBlue:
- return EPGSearchConfig.useOkForSwitch?ShowSummary():Switch();
+ case kBlue:
+ return EPGSearchConfig.useOkForSwitch ? ShowSummary() : Switch();
break;
- case kOk:
- if(HasSubMenu())
- {
- state = cOsdMenu::ProcessKey(Key);
- break;
+ case kOk:
+ if (HasSubMenu()) {
+ state = cOsdMenu::ProcessKey(Key);
+ break;
}
if (Count())
- state = EPGSearchConfig.useOkForSwitch?Switch():ShowSummary();
+ state = EPGSearchConfig.useOkForSwitch ? Switch() : ShowSummary();
else
- state = osBack;
+ state = osBack;
break;
- default:
+ default:
break;
- }
- }
- return state;
+ }
+ }
+ return state;
}
void cMenuFavorites::SetHelpKeys(bool Force)
{
- cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
- int NewHelpKeys = 0;
- if (item) {
- if (item->Selectable() && item->timerMatch == tmFull)
- NewHelpKeys = 2;
- else
- NewHelpKeys = 1;
- }
-
- bool hasTimer = (NewHelpKeys == 2);
- if (NewHelpKeys != helpKeys || Force)
- {
- showMode nextShowMode = cMenuWhatsOnSearch::GetNextMode();
- cShowMode* mode = cMenuWhatsOnSearch::GetShowMode(nextShowMode);
- const char* szButtonGreen = NULL;
- if (mode)
- szButtonGreen = mode->GetDescription();
-
- if (toggleKeys==0)
- SetHelp((EPGSearchConfig.redkeymode==0?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), szButtonGreen,trVDR("Button$Schedule"), EPGSearchConfig.useOkForSwitch?trVDR("Button$Info"):trVDR("Button$Switch"));
- else
- SetHelp((EPGSearchConfig.redkeymode==1?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), szButtonGreen,trVDR("Button$Schedule"), EPGSearchConfig.useOkForSwitch?trVDR("Button$Info"):trVDR("Button$Switch"));
- helpKeys = NewHelpKeys;
+ cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
+ int NewHelpKeys = 0;
+ if (item) {
+ if (item->Selectable() && item->timerMatch == tmFull)
+ NewHelpKeys = 2;
+ else
+ NewHelpKeys = 1;
+ }
+
+ bool hasTimer = (NewHelpKeys == 2);
+ if (NewHelpKeys != helpKeys || Force) {
+ showMode nextShowMode = cMenuWhatsOnSearch::GetNextMode();
+ cShowMode* mode = cMenuWhatsOnSearch::GetShowMode(nextShowMode);
+ const char* szButtonGreen = NULL;
+ if (mode)
+ szButtonGreen = mode->GetDescription();
+
+ if (toggleKeys == 0)
+ SetHelp((EPGSearchConfig.redkeymode == 0 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), szButtonGreen, trVDR("Button$Schedule"), EPGSearchConfig.useOkForSwitch ? trVDR("Button$Info") : trVDR("Button$Switch"));
+ else
+ SetHelp((EPGSearchConfig.redkeymode == 1 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), szButtonGreen, trVDR("Button$Schedule"), EPGSearchConfig.useOkForSwitch ? trVDR("Button$Info") : trVDR("Button$Switch"));
+ helpKeys = NewHelpKeys;
}
}
diff --git a/menu_favorites.h b/menu_favorites.h
index 5adf9f7..d012fb4 100644
--- a/menu_favorites.h
+++ b/menu_favorites.h
@@ -26,18 +26,19 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "menu_searchresults.h"
-class cMenuFavorites : public cMenuSearchResults {
- private:
+class cMenuFavorites : public cMenuSearchResults
+{
+private:
bool BuildList();
virtual eOSState OnGreen();
virtual eOSState OnYellow();
- public:
+public:
cMenuFavorites();
virtual eOSState ProcessKey(eKeys Key);
- virtual void SetHelpKeys(bool Force=false);
+ virtual void SetHelpKeys(bool Force = false);
#ifdef USE_GRAPHTFT
- virtual const char* MenuKind();
- virtual void Display(void);
+ virtual const char* MenuKind();
+ virtual void Display(void);
#endif
};
diff --git a/menu_main.c b/menu_main.c
index f0b81b6..1917a82 100644
--- a/menu_main.c
+++ b/menu_main.c
@@ -39,7 +39,7 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "menu_deftimercheckmethod.h"
#include "timerstatus.h"
-int toggleKeys=0;
+int toggleKeys = 0;
int exitToMainMenu = 0;
extern int gl_InfoConflict;
@@ -47,54 +47,52 @@ int cMenuSearchMain::forceMenu = 0; // 1 = now, 2 = schedule, 3 = summary
// --- cMenuSearchMain ---------------------------------------------------------
cMenuSearchMain::cMenuSearchMain(void)
-:cOsdMenu("", GetTab(1), GetTab(2), GetTab(3), GetTab(4), GetTab(5))
+ : cOsdMenu("", GetTab(1), GetTab(2), GetTab(3), GetTab(4), GetTab(5))
{
- SetMenuCategory(mcSchedule);
- helpKeys = -1;
- otherChannel = 0;
- toggleKeys = 0;
- shiftTime = 0;
- InWhatsOnMenu = false;
- InFavoritesMenu = false;
- const cChannel *channel;
- {
- LOCK_CHANNELS_READ;
- channel = Channels->GetByNumber(cDevice::CurrentChannel());
- }
- if (channel) {
- cMenuWhatsOnSearch::SetCurrentChannel(channel->Number());
- if (EPGSearchConfig.StartMenu == 0 || forceMenu != 0)
- PrepareSchedule(channel);
- SetHelpKeys();
- cMenuWhatsOnSearch::currentShowMode = showNow;
- // timeb tnow;
- //ftime(&tnow);
- //isyslog("duration epgs sched: %d", tnow.millitm - gl_time.millitm + ((tnow.millitm - gl_time.millitm<0)?1000:0));
-
- }
- if ((EPGSearchConfig.StartMenu == 1 || forceMenu == 1) && forceMenu != 2)
- {
- InWhatsOnMenu = true;
- AddSubMenu(new cMenuWhatsOnSearch(cDevice::CurrentChannel()));
- }
- if (forceMenu == 3)
- ShowSummary();
+ SetMenuCategory(mcSchedule);
+ helpKeys = -1;
+ otherChannel = 0;
+ toggleKeys = 0;
+ shiftTime = 0;
+ InWhatsOnMenu = false;
+ InFavoritesMenu = false;
+ const cChannel *channel;
+ {
+ LOCK_CHANNELS_READ;
+ channel = Channels->GetByNumber(cDevice::CurrentChannel());
+ }
+ if (channel) {
+ cMenuWhatsOnSearch::SetCurrentChannel(channel->Number());
+ if (EPGSearchConfig.StartMenu == 0 || forceMenu != 0)
+ PrepareSchedule(channel);
+ SetHelpKeys();
+ cMenuWhatsOnSearch::currentShowMode = showNow;
+ // timeb tnow;
+ //ftime(&tnow);
+ //isyslog("duration epgs sched: %d", tnow.millitm - gl_time.millitm + ((tnow.millitm - gl_time.millitm<0)?1000:0));
+
+ }
+ if ((EPGSearchConfig.StartMenu == 1 || forceMenu == 1) && forceMenu != 2) {
+ InWhatsOnMenu = true;
+ AddSubMenu(new cMenuWhatsOnSearch(cDevice::CurrentChannel()));
+ }
+ if (forceMenu == 3)
+ ShowSummary();
}
#ifdef USE_GRAPHTFT
void cMenuSearchMain::Display(void)
{
- cOsdMenu::Display();
+ cOsdMenu::Display();
- if (Count() > 0)
- {
- int i = 0;
+ if (Count() > 0) {
+ int i = 0;
- for (cOsdItem *item = First(); item; item = Next(item))
- cStatus::MsgOsdEventItem(!item->Selectable() ? 0 :
- ((cMenuMyScheduleItem*)item)->event,
- item->Text(), i++, Count());
- }
+ for (cOsdItem *item = First(); item; item = Next(item))
+ cStatus::MsgOsdEventItem(!item->Selectable() ? 0 :
+ ((cMenuMyScheduleItem*)item)->event,
+ item->Text(), i++, Count());
+ }
}
#endif /* GRAPHTFT */
@@ -106,7 +104,7 @@ cMenuSearchMain::~cMenuSearchMain()
int cMenuSearchMain::GetTab(int Tab)
{
- return cTemplFile::GetTemplateByName("MenuSchedule")->Tab(Tab-1);
+ return cTemplFile::GetTemplateByName("MenuSchedule")->Tab(Tab - 1);
}
void cMenuSearchMain::PrepareSchedule(const cChannel *Channel)
@@ -118,159 +116,147 @@ void cMenuSearchMain::PrepareSchedule(const cChannel *Channel)
cMenuTemplate* ScheduleTemplate = cTemplFile::GetTemplateByName("MenuSchedule");
eventObjects.Clear();
- LOCK_TIMERS_READ;
- const cSchedule *Schedule;
- {
- LOCK_SCHEDULES_READ;
- Schedule = Schedules->GetSchedule(Channel);
- }
- currentChannel = Channel->Number();
- if (Schedule && Schedule->Events()->First())
- {
- const cEvent *PresentEvent = Schedule->GetPresentEvent();
- time_t now = time(NULL);
- now -= Setup.EPGLinger * 60;
- if (shiftTime != 0)
- PresentEvent = Schedule->GetEventAround(time(NULL) + shiftTime * 60);
-
- time_t lastEventDate = Schedule->Events()->First()->StartTime();
-
- // timeb tstart;
- // ftime(&tstart);
- for (const cEvent *Event = Schedule->Events()->First(); Event; Event = Schedule->Events()->Next(Event)) {
- if (Event->EndTime() > now || (shiftTime==0 && Event == PresentEvent))
- {
- if (EPGSearchConfig.showDaySeparators)
- {
- struct tm tm_rEvent;
- struct tm tm_rLastEvent;
- time_t EventDate = Event->StartTime();
- struct tm *t_event = localtime_r(&EventDate, &tm_rEvent);
- struct tm *t_lastevent = localtime_r(&lastEventDate, &tm_rLastEvent);
- if (t_event->tm_mday != t_lastevent->tm_mday)
- Add(new cMenuMyScheduleSepItem(NULL, Event));
- lastEventDate = EventDate;
- }
- Add(new cMenuMyScheduleItem(Timers, Event, NULL, showNow, ScheduleTemplate), Event == PresentEvent);
- eventObjects.Add(Event);
- }
+ LOCK_TIMERS_READ;
+ const cSchedule *Schedule;
+ {
+ LOCK_SCHEDULES_READ;
+ Schedule = Schedules->GetSchedule(Channel);
+ }
+ currentChannel = Channel->Number();
+ if (Schedule && Schedule->Events()->First()) {
+ const cEvent *PresentEvent = Schedule->GetPresentEvent();
+ time_t now = time(NULL);
+ now -= Setup.EPGLinger * 60;
+ if (shiftTime != 0)
+ PresentEvent = Schedule->GetEventAround(time(NULL) + shiftTime * 60);
+
+ time_t lastEventDate = Schedule->Events()->First()->StartTime();
+
+ // timeb tstart;
+ // ftime(&tstart);
+ for (const cEvent *Event = Schedule->Events()->First(); Event; Event = Schedule->Events()->Next(Event)) {
+ if (Event->EndTime() > now || (shiftTime == 0 && Event == PresentEvent)) {
+ if (EPGSearchConfig.showDaySeparators) {
+ struct tm tm_rEvent;
+ struct tm tm_rLastEvent;
+ time_t EventDate = Event->StartTime();
+ struct tm *t_event = localtime_r(&EventDate, &tm_rEvent);
+ struct tm *t_lastevent = localtime_r(&lastEventDate, &tm_rLastEvent);
+ if (t_event->tm_mday != t_lastevent->tm_mday)
+ Add(new cMenuMyScheduleSepItem(NULL, Event));
+ lastEventDate = EventDate;
+ }
+ Add(new cMenuMyScheduleItem(Timers, Event, NULL, showNow, ScheduleTemplate), Event == PresentEvent);
+ eventObjects.Add(Event);
}
- // timeb tnow;
- // ftime(&tnow);
- // isyslog("duration epgs prepsched: %d (%d)", tnow.millitm - tstart.millitm + ((tnow.millitm - tstart.millitm<0)?1000:0), Count());
+ }
+ // timeb tnow;
+ // ftime(&tnow);
+ // isyslog("duration epgs prepsched: %d (%d)", tnow.millitm - tstart.millitm + ((tnow.millitm - tstart.millitm<0)?1000:0), Count());
}
- if (shiftTime)
- {
- cString buffer = cString::sprintf("%s (%s%dh %dm)", Channel->Name(), shiftTime>0?"+":"",
- shiftTime/60, abs(shiftTime)%60);
- SetTitle(buffer);
+ if (shiftTime) {
+ cString buffer = cString::sprintf("%s (%s%dh %dm)", Channel->Name(), shiftTime > 0 ? "+" : "",
+ shiftTime / 60, abs(shiftTime) % 60);
+ SetTitle(buffer);
}
}
bool cMenuSearchMain::Update(void)
{
- bool result = false;
- LOCK_TIMERS_READ;
- for (cOsdItem *item = First(); item; item = Next(item)) {
- if (item->Selectable() && ((cMenuMyScheduleItem *)item)->Update(Timers))
- result = true;
- }
- return result;
+ bool result = false;
+ LOCK_TIMERS_READ;
+ for (cOsdItem *item = First(); item; item = Next(item)) {
+ if (item->Selectable() && ((cMenuMyScheduleItem *)item)->Update(Timers))
+ result = true;
+ }
+ return result;
}
eOSState cMenuSearchMain::Record(void)
{
- cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)Get(Current());
- if (item) {
- LOCK_TIMERS_WRITE;
- Timers->SetExplicitModify();
- if (item->timerMatch == tmFull)
- {
- eTimerMatch tm = tmNone;
- cTimer *timer = Timers->GetMatch(item->event, &tm);
- if (timer)
- {
- if (EPGSearchConfig.useVDRTimerEditMenu)
- return AddSubMenu(new cMenuEditTimer(timer));
- else
- return AddSubMenu(new cMenuMyEditTimer(timer, false, item->event, item->channel));
- }
- }
-
- cTimer *timer = new cTimer(item->event);
- PrepareTimerFile(item->event, timer);
-
- cTimer *t = Timers->GetTimer(timer);
- if (EPGSearchConfig.onePressTimerCreation == 0 || t || !item->event || (!t && item->event && item->event->StartTime() - (Setup.MarginStart+2) * 60 < time(NULL)))
- {
- if (t)
- {
- delete timer;
- timer = t;
- }
- if (EPGSearchConfig.useVDRTimerEditMenu)
- return AddSubMenu(new cMenuEditTimer(timer, !t));
- else
- return AddSubMenu(new cMenuMyEditTimer(timer, !t, item->event));
- }
- else
- {
- string fullaux = "";
- string aux = "";
- if (item->event)
- {
- const cEvent* event = item->event;
- int bstart = event->StartTime() - timer->StartTime();
- int bstop = timer->StopTime() - event->EndTime();
- int checkmode = DefTimerCheckModes.GetMode(timer->Channel());
- aux = UpdateAuxValue(aux, "channel", NumToString(timer->Channel()->Number()) + " - " + CHANNELNAME(timer->Channel()));
- aux = UpdateAuxValue(aux, "update", checkmode);
- aux = UpdateAuxValue(aux, "eventid", event->EventID());
- aux = UpdateAuxValue(aux, "bstart", bstart);
- aux = UpdateAuxValue(aux, "bstop", bstop);
- fullaux = UpdateAuxValue(fullaux, "epgsearch", aux);
- }
+ cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)Get(Current());
+ if (item) {
+ LOCK_TIMERS_WRITE;
+ Timers->SetExplicitModify();
+ if (item->timerMatch == tmFull) {
+ eTimerMatch tm = tmNone;
+ cTimer *timer = Timers->GetMatch(item->event, &tm);
+ if (timer) {
+ if (EPGSearchConfig.useVDRTimerEditMenu)
+ return AddSubMenu(new cMenuEditTimer(timer));
+ else
+ return AddSubMenu(new cMenuMyEditTimer(timer, false, item->event, item->channel));
+ }
+ }
+
+ cTimer *timer = new cTimer(item->event);
+ PrepareTimerFile(item->event, timer);
+
+ cTimer *t = Timers->GetTimer(timer);
+ if (EPGSearchConfig.onePressTimerCreation == 0 || t || !item->event || (!t && item->event && item->event->StartTime() - (Setup.MarginStart + 2) * 60 < time(NULL))) {
+ if (t) {
+ delete timer;
+ timer = t;
+ }
+ if (EPGSearchConfig.useVDRTimerEditMenu)
+ return AddSubMenu(new cMenuEditTimer(timer, !t));
+ else
+ return AddSubMenu(new cMenuMyEditTimer(timer, !t, item->event));
+ } else {
+ string fullaux = "";
+ string aux = "";
+ if (item->event) {
+ const cEvent* event = item->event;
+ int bstart = event->StartTime() - timer->StartTime();
+ int bstop = timer->StopTime() - event->EndTime();
+ int checkmode = DefTimerCheckModes.GetMode(timer->Channel());
+ aux = UpdateAuxValue(aux, "channel", NumToString(timer->Channel()->Number()) + " - " + CHANNELNAME(timer->Channel()));
+ aux = UpdateAuxValue(aux, "update", checkmode);
+ aux = UpdateAuxValue(aux, "eventid", event->EventID());
+ aux = UpdateAuxValue(aux, "bstart", bstart);
+ aux = UpdateAuxValue(aux, "bstop", bstop);
+ fullaux = UpdateAuxValue(fullaux, "epgsearch", aux);
+ }
#ifdef USE_PINPLUGIN
- aux = "";
- aux = UpdateAuxValue(aux, "protected", timer->FskProtection() ? "yes" : "no");
- fullaux = UpdateAuxValue(fullaux, "pin-plugin", aux);
+ aux = "";
+ aux = UpdateAuxValue(aux, "protected", timer->FskProtection() ? "yes" : "no");
+ fullaux = UpdateAuxValue(fullaux, "pin-plugin", aux);
#endif
- SetAux(timer, fullaux);
- if (Setup.SVDRPPeering && *Setup.SVDRPDefaultHost)
- timer->SetRemote(Setup.SVDRPDefaultHost);
- Timers->Add(timer);
- Timers->SetModified();
- gl_timerStatusMonitor->SetConflictCheckAdvised();
- timer->Matches();
- if (!HandleRemoteTimerModifications(timer)) {
- ERROR(tr("Epgsearch: RemoteTimerModifications failed"));
- Timers->Del(timer);
- }
- else
- LogFile.iSysLog("timer %s added (active)", *timer->ToDescr());
-
- if (HasSubMenu())
- CloseSubMenu();
- if (Update())
- Display();
- SetHelpKeys();
- }
- }
- return osContinue;
+ SetAux(timer, fullaux);
+ if (Setup.SVDRPPeering && *Setup.SVDRPDefaultHost)
+ timer->SetRemote(Setup.SVDRPDefaultHost);
+ Timers->Add(timer);
+ Timers->SetModified();
+ gl_timerStatusMonitor->SetConflictCheckAdvised();
+ timer->Matches();
+ if (!HandleRemoteTimerModifications(timer)) {
+ ERROR(tr("Epgsearch: RemoteTimerModifications failed"));
+ Timers->Del(timer);
+ } else
+ LogFile.iSysLog("timer %s added (active)", *timer->ToDescr());
+
+ if (HasSubMenu())
+ CloseSubMenu();
+ if (Update())
+ Display();
+ SetHelpKeys();
+ }
+ }
+ return osContinue;
}
eOSState cMenuSearchMain::Switch(void)
{
- cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)Get(Current());
- if (item) {
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(item->event->ChannelID(), true, true);
- if (channel && cDevice::PrimaryDevice()->SwitchChannel(channel, true))
- return osEnd;
- }
- INFO(trVDR("Can't switch channel!"));
- return osContinue;
+ cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)Get(Current());
+ if (item) {
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(item->event->ChannelID(), true, true);
+ if (channel && cDevice::PrimaryDevice()->SwitchChannel(channel, true))
+ return osEnd;
+ }
+ INFO(trVDR("Can't switch channel!"));
+ return osContinue;
}
eOSState cMenuSearchMain::ExtendedSearch(void)
@@ -280,57 +266,54 @@ eOSState cMenuSearchMain::ExtendedSearch(void)
eOSState cMenuSearchMain::Commands(eKeys Key)
{
- if (HasSubMenu() || Count() == 0)
- return osContinue;
- cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
- if (mi && mi->event) {
+ if (HasSubMenu() || Count() == 0)
+ return osContinue;
+ cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
+ if (mi && mi->event) {
cMenuSearchCommands *menu;
eOSState state = AddSubMenu(menu = new cMenuSearchCommands(tr("EPG Commands"), mi->event, true));
if (Key != kNone)
- state = menu->ProcessKey(Key);
+ state = menu->ProcessKey(Key);
return state;
- }
- return osContinue;
+ }
+ return osContinue;
}
eOSState cMenuSearchMain::ShowSummary()
{
- if (Count())
- {
- cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
- if (mi && mi->event)
- return AddSubMenu(new cMenuEventSearch(mi->event, eventObjects, SurfModeTime));
- }
- return osContinue;
+ if (Count()) {
+ cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
+ if (mi && mi->event)
+ return AddSubMenu(new cMenuEventSearch(mi->event, eventObjects, SurfModeTime));
+ }
+ return osContinue;
}
void cMenuSearchMain::SetHelpKeys(bool Force)
{
cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)Get(Current());
int NewHelpKeys = 0;
- if (item) {
- if (item->Selectable() && item->timerMatch == tmFull)
- NewHelpKeys = 2;
- else
- NewHelpKeys = 1;
+ if (item) {
+ if (item->Selectable() && item->timerMatch == tmFull)
+ NewHelpKeys = 2;
+ else
+ NewHelpKeys = 1;
}
bool hasTimer = (NewHelpKeys == 2);
- if (NewHelpKeys != helpKeys || Force)
- {
- if (toggleKeys==0)
- SetHelp((EPGSearchConfig.redkeymode==0?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), trVDR("Button$Now"), trVDR("Button$Next"), EPGSearchConfig.bluekeymode==0?trVDR("Button$Switch"):tr("Button$Search"));
- else
- {
- LOCK_CHANNELS_READ;
- const char* szGreenToggled = CHANNELNAME(Channels->GetByNumber(currentChannel-1,-1));
- const char* szYellowToggled = CHANNELNAME(Channels->GetByNumber(currentChannel+1,1));
-
- SetHelp((EPGSearchConfig.redkeymode==1?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), (EPGSearchConfig.toggleGreenYellow==0?trVDR("Button$Now"):szGreenToggled), (EPGSearchConfig.toggleGreenYellow==0?trVDR("Button$Next"):szYellowToggled), EPGSearchConfig.bluekeymode==1?trVDR("Button$Switch"):tr("Button$Search"));
-
- }
- helpKeys = NewHelpKeys;
- }
+ if (NewHelpKeys != helpKeys || Force) {
+ if (toggleKeys == 0)
+ SetHelp((EPGSearchConfig.redkeymode == 0 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), trVDR("Button$Now"), trVDR("Button$Next"), EPGSearchConfig.bluekeymode == 0 ? trVDR("Button$Switch") : tr("Button$Search"));
+ else {
+ LOCK_CHANNELS_READ;
+ const char* szGreenToggled = CHANNELNAME(Channels->GetByNumber(currentChannel - 1, -1));
+ const char* szYellowToggled = CHANNELNAME(Channels->GetByNumber(currentChannel + 1, 1));
+
+ SetHelp((EPGSearchConfig.redkeymode == 1 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), (EPGSearchConfig.toggleGreenYellow == 0 ? trVDR("Button$Now") : szGreenToggled), (EPGSearchConfig.toggleGreenYellow == 0 ? trVDR("Button$Next") : szYellowToggled), EPGSearchConfig.bluekeymode == 1 ? trVDR("Button$Switch") : tr("Button$Search"));
+
+ }
+ helpKeys = NewHelpKeys;
+ }
}
eOSState cMenuSearchMain::Shift(int iMinutes)
@@ -346,17 +329,16 @@ eOSState cMenuSearchMain::Shift(int iMinutes)
void cMenuSearchMain::UpdateCurrent()
{
- // navigation in summary could have changed current item, so update it
- cEventObj* cureventObj = eventObjects.GetCurrent();
- if (cureventObj && cureventObj->Event())
- for (cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)First(); item; item = (cMenuMyScheduleItem *)Next(item))
- if (item->Selectable() && item->event == cureventObj->Event())
- {
- cureventObj->Select(false);
- SetCurrent(item);
- Display();
- break;
- }
+ // navigation in summary could have changed current item, so update it
+ cEventObj* cureventObj = eventObjects.GetCurrent();
+ if (cureventObj && cureventObj->Event())
+ for (cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)First(); item; item = (cMenuMyScheduleItem *)Next(item))
+ if (item->Selectable() && item->event == cureventObj->Event()) {
+ cureventObj->Select(false);
+ SetCurrent(item);
+ Display();
+ break;
+ }
}
eOSState cMenuSearchMain::ProcessKey(eKeys Key)
@@ -364,221 +346,190 @@ eOSState cMenuSearchMain::ProcessKey(eKeys Key)
bool HadSubMenu = HasSubMenu();
eOSState state = cOsdMenu::ProcessKey(Key);
- if (exitToMainMenu == 1)
- {
- exitToMainMenu = 0;
- return osBack;
+ if (exitToMainMenu == 1) {
+ exitToMainMenu = 0;
+ return osBack;
}
- if (!HasSubMenu() && HadSubMenu)
- UpdateCurrent();
+ if (!HasSubMenu() && HadSubMenu)
+ UpdateCurrent();
if (state == osUnknown) {
- switch (Key) {
- case kFastRew:
- if (HasSubMenu() && !InWhatsOnMenu && !InFavoritesMenu)
- {
-/* if (Count())
- {
- CursorUp();
- return ShowSummary();
+ switch (Key) {
+ case kFastRew:
+ if (HasSubMenu() && !InWhatsOnMenu && !InFavoritesMenu) {
+ /* if (Count())
+ {
+ CursorUp();
+ return ShowSummary();
+ }
+ */
+ } else
+ return Shift(-EPGSearchConfig.timeShiftValue);
+ case kFastFwd:
+ if (HasSubMenu() && !InWhatsOnMenu && !InFavoritesMenu) {
+ /* if (Count())
+ {
+ CursorDown();
+ return ShowSummary();
+ }
+ */
+ } else
+ return Shift(EPGSearchConfig.timeShiftValue);
+ case kRecord:
+ case kRed:
+ if (HasSubMenu()) {
+ UpdateCurrent();
+ state = Record();
+ break;
}
-*/ }
- else
- return Shift(-EPGSearchConfig.timeShiftValue);
- case kFastFwd:
- if (HasSubMenu() && !InWhatsOnMenu && !InFavoritesMenu)
- {
-/* if (Count())
- {
- CursorDown();
- return ShowSummary();
- }
-*/ }
- else
- return Shift(EPGSearchConfig.timeShiftValue);
- case kRecord:
- case kRed:
- if(HasSubMenu()) {
- UpdateCurrent();
- state = Record();
+ if (Count()) {
+ if (EPGSearchConfig.redkeymode == toggleKeys)
+ state = Record();
+ else {
+ cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
+ if (mi) {
+ if (mi->event) {
+ return AddSubMenu(new cMenuSearchCommands(tr("EPG Commands"), mi->event));
+ }
+ }
+ }
+ }
+ break;
+ case k0:
+ if (!HasSubMenu()) {
+ toggleKeys = 1 - toggleKeys;
+ SetHelpKeys(true);
+ }
+ state = osContinue;
+ break;
+ case k1...k9:
+ if (!HasSubMenu())
+ return Commands(Key);
+ else
+ state = osContinue;
+ break;
+ case kGreen: {
+ if (HasSubMenu() && !InWhatsOnMenu && !InFavoritesMenu) {
+ if (Count()) {
+// CursorUp();
+// return ShowSummary();
+ }
+ } else if (toggleKeys == 0 || (toggleKeys == 1 && EPGSearchConfig.toggleGreenYellow == 0)) {
+ int ChannelNr = cDevice::CurrentChannel();
+ if (Count()) {
+ cMenuMyScheduleItem* Item = (cMenuMyScheduleItem *)Get(Current());
+ if (Item && Item->event) {
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(Item->event->ChannelID(), true, true);
+ if (channel)
+ ChannelNr = channel->Number();
+ }
+ }
+ if (cMenuWhatsOnSearch::currentShowMode == showFavorites) {
+ InFavoritesMenu = true;
+ return AddSubMenu(new cMenuFavorites());
+ } else {
+ InWhatsOnMenu = true;
+ return AddSubMenu(new cMenuWhatsOnSearch(ChannelNr));
+ }
+ } else {
+ const cChannel *channel;
+ {
+ LOCK_CHANNELS_READ;
+ channel = Channels->GetByNumber(currentChannel - 1, -1);
+ }
+
+ if (channel) {
+ PrepareSchedule(channel);
+ if (channel->Number() != cDevice::CurrentChannel()) {
+ otherChannel = channel->Number();
+ }
+ Display();
+ }
+ SetHelpKeys(true);
+ return osContinue;
+ }
+ }
+ case kYellow: {
+ if (HasSubMenu()) {
+ if (Count()) {
+// CursorDown();
+// return ShowSummary();
+ }
+ } else if (toggleKeys == 0 || (toggleKeys == 1 && EPGSearchConfig.toggleGreenYellow == 0)) {
+ cMenuWhatsOnSearch::currentShowMode = showNext;
+ InWhatsOnMenu = true;
+ return AddSubMenu(new cMenuWhatsOnSearch(cMenuWhatsOnSearch::CurrentChannel()));
+ } else {
+ const cChannel *channel;
+ {
+ LOCK_CHANNELS_READ;
+ channel = Channels->GetByNumber(currentChannel + 1, 1);
+ }
+ if (channel) {
+ PrepareSchedule(channel);
+ if (channel->Number() != cDevice::CurrentChannel()) {
+ otherChannel = channel->Number();
+ }
+ Display();
+ }
+ SetHelpKeys(true);
+ return osContinue;
+ }
+ break;
+ }
+ case kBlue:
+ if (HasSubMenu()) {
+ UpdateCurrent();
+ return Switch();
+ }
+ if (EPGSearchConfig.bluekeymode == toggleKeys)
+ return Switch();
+ else
+ return ExtendedSearch();
+ break;
+ case kInfo:
+ case kOk:
+ if (Count())
+ return ShowSummary();
+ break;
+ default:
break;
- }
- if (Count())
- {
- if (EPGSearchConfig.redkeymode==toggleKeys)
- state = Record();
- else
- {
- cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
- if (mi) {
- if (mi->event) {
- return AddSubMenu(new cMenuSearchCommands(tr("EPG Commands"),mi->event));
- }
- }
- }
- }
- break;
- case k0:
- if(!HasSubMenu())
- {
- toggleKeys = 1 - toggleKeys;
- SetHelpKeys(true);
- }
- state = osContinue;
- break;
- case k1...k9:
- if (!HasSubMenu())
- return Commands(Key);
- else
- state = osContinue;
- break;
- case kGreen:
- {
- if (HasSubMenu() && !InWhatsOnMenu && !InFavoritesMenu)
- {
- if (Count())
- {
-// CursorUp();
-// return ShowSummary();
- }
- }
- else if (toggleKeys == 0 || (toggleKeys == 1 && EPGSearchConfig.toggleGreenYellow == 0))
- {
- int ChannelNr = cDevice::CurrentChannel();
- if (Count()) {
- cMenuMyScheduleItem* Item = (cMenuMyScheduleItem *)Get(Current());
- if (Item && Item->event)
- {
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(Item->event->ChannelID(), true, true);
- if (channel)
- ChannelNr = channel->Number();
- }
- }
- if (cMenuWhatsOnSearch::currentShowMode == showFavorites)
- {
- InFavoritesMenu = true;
- return AddSubMenu(new cMenuFavorites());
- }
- else
- {
- InWhatsOnMenu = true;
- return AddSubMenu(new cMenuWhatsOnSearch(ChannelNr));
- }
- }
- else
- {
- const cChannel *channel;
- {
- LOCK_CHANNELS_READ;
- channel = Channels->GetByNumber(currentChannel-1,-1);
- }
-
- if (channel) {
- PrepareSchedule(channel);
- if (channel->Number() != cDevice::CurrentChannel()) {
- otherChannel = channel->Number();
- }
- Display();
- }
- SetHelpKeys(true);
- return osContinue;
- }
- }
- case kYellow:
- {
- if (HasSubMenu())
- {
- if (Count())
- {
-// CursorDown();
-// return ShowSummary();
- }
- }
- else if (toggleKeys == 0 || (toggleKeys == 1 && EPGSearchConfig.toggleGreenYellow == 0))
- {
- cMenuWhatsOnSearch::currentShowMode = showNext;
- InWhatsOnMenu = true;
- return AddSubMenu(new cMenuWhatsOnSearch(cMenuWhatsOnSearch::CurrentChannel()));
- }
- else
- {
- const cChannel *channel;
- {
- LOCK_CHANNELS_READ;
- channel = Channels->GetByNumber(currentChannel+1,1);
- }
- if (channel) {
- PrepareSchedule(channel);
- if (channel->Number() != cDevice::CurrentChannel()) {
- otherChannel = channel->Number();
- }
- Display();
- }
- SetHelpKeys(true);
- return osContinue;
- }
- break;
- }
- case kBlue:
- if (HasSubMenu())
- {
- UpdateCurrent();
- return Switch();
}
- if (EPGSearchConfig.bluekeymode==toggleKeys)
- return Switch();
- else
- return ExtendedSearch();
- break;
- case kInfo:
- case kOk:
- if (Count())
- return ShowSummary();
- break;
- default:
- break;
- }
}
if (!HasSubMenu()) {
- const cChannel *ch = cMenuWhatsOnSearch::ScheduleChannel();
- InWhatsOnMenu = false;
- InFavoritesMenu = false;
- if (ch) {
- // when switch from the other menus to the schedule, try to keep the same time
- if (cMenuWhatsOnSearch::shiftTime)
- {
- time_t diff = cMenuWhatsOnSearch::seekTime - time(NULL);
- shiftTime = (diff + (diff>0?30:-30)) / 60 ;
- }
- else
- shiftTime = 0;
-
- PrepareSchedule(ch);
- if (ch->Number() != cDevice::CurrentChannel()) {
- otherChannel = ch->Number();
- }
- Display();
- }
- else if ((HadSubMenu || gl_TimerProgged) && Update())
- {
- if (gl_TimerProgged) // when using epgsearch's timer edit menu, update is delayed because of SVDRP
- {
- gl_TimerProgged = 0;
- SetHelpKeys();
- }
- Display();
- }
- if (Key != kNone)
- SetHelpKeys();
- if (gl_InfoConflict)
- {
- gl_InfoConflict = 0;
- if (Interface->Confirm(tr("Timer conflict! Show?")))
- return AddSubMenu(new cMenuConflictCheck());
- }
- }
- return state;
+ const cChannel *ch = cMenuWhatsOnSearch::ScheduleChannel();
+ InWhatsOnMenu = false;
+ InFavoritesMenu = false;
+ if (ch) {
+ // when switch from the other menus to the schedule, try to keep the same time
+ if (cMenuWhatsOnSearch::shiftTime) {
+ time_t diff = cMenuWhatsOnSearch::seekTime - time(NULL);
+ shiftTime = (diff + (diff > 0 ? 30 : -30)) / 60 ;
+ } else
+ shiftTime = 0;
+
+ PrepareSchedule(ch);
+ if (ch->Number() != cDevice::CurrentChannel()) {
+ otherChannel = ch->Number();
+ }
+ Display();
+ } else if ((HadSubMenu || gl_TimerProgged) && Update()) {
+ if (gl_TimerProgged) { // when using epgsearch's timer edit menu, update is delayed because of SVDRP
+ gl_TimerProgged = 0;
+ SetHelpKeys();
+ }
+ Display();
+ }
+ if (Key != kNone)
+ SetHelpKeys();
+ if (gl_InfoConflict) {
+ gl_InfoConflict = 0;
+ if (Interface->Confirm(tr("Timer conflict! Show?")))
+ return AddSubMenu(new cMenuConflictCheck());
+ }
+ }
+ return state;
}
diff --git a/menu_main.h b/menu_main.h
index 96567a1..a498ed5 100644
--- a/menu_main.h
+++ b/menu_main.h
@@ -29,36 +29,39 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
// --- cMenuSearchMain ---------------------------------------------------------
-class cMenuSearchMain : public cOsdMenu {
- private:
- int helpKeys;
- int otherChannel;
- int currentChannel;
- eOSState Record(void);
- eOSState ExtendedSearch(void);
- void PrepareSchedule(const cChannel *Channel);
- eOSState Commands(eKeys Key);
- void SetHelpKeys(bool Force = false);
- int GetTab(int Tab);
- int shiftTime;
- bool InWhatsOnMenu;
- bool InFavoritesMenu;
- cEventObjects eventObjects;
- public:
- cMenuSearchMain(void);
- virtual ~cMenuSearchMain();
- virtual eOSState ProcessKey(eKeys Key);
- eOSState Switch(void);
- eOSState Shift(int iMinutes);
- eOSState ShowSummary();
- bool Update(void);
- void UpdateCurrent();
+class cMenuSearchMain : public cOsdMenu
+{
+private:
+ int helpKeys;
+ int otherChannel;
+ int currentChannel;
+ eOSState Record(void);
+ eOSState ExtendedSearch(void);
+ void PrepareSchedule(const cChannel *Channel);
+ eOSState Commands(eKeys Key);
+ void SetHelpKeys(bool Force = false);
+ int GetTab(int Tab);
+ int shiftTime;
+ bool InWhatsOnMenu;
+ bool InFavoritesMenu;
+ cEventObjects eventObjects;
+public:
+ cMenuSearchMain(void);
+ virtual ~cMenuSearchMain();
+ virtual eOSState ProcessKey(eKeys Key);
+ eOSState Switch(void);
+ eOSState Shift(int iMinutes);
+ eOSState ShowSummary();
+ bool Update(void);
+ void UpdateCurrent();
#ifdef USE_GRAPHTFT
- virtual const char* MenuKind() { return "MenuEpgsSchedule"; }
- virtual void Display(void);
+ virtual const char* MenuKind() {
+ return "MenuEpgsSchedule";
+ }
+ virtual void Display(void);
#endif
- static int forceMenu;
+ static int forceMenu;
};
#endif
diff --git a/menu_myedittimer.c b/menu_myedittimer.c
index 238c3b1..3a4bc5f 100644
--- a/menu_myedittimer.c
+++ b/menu_myedittimer.c
@@ -38,9 +38,9 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
const char *cMenuMyEditTimer::CheckModes[3];
cMenuMyEditTimer::cMenuMyEditTimer(cTimer *Timer, bool New, const cEvent* Event, const cChannel* forcechannel)
-:cOsdMenu(trVDR("Edit timer"), 14)
+ : cOsdMenu(trVDR("Edit timer"), 14)
{
- SetMenuCategory(mcTimerEdit);
+ SetMenuCategory(mcTimerEdit);
CheckModes[0] = tr("no check");
CheckModes[UPD_CHDUR] = tr("by channel and time");
CheckModes[UPD_EVENTID] = tr("by event ID");
@@ -50,72 +50,61 @@ cMenuMyEditTimer::cMenuMyEditTimer(cTimer *Timer, bool New, const cEvent* Event,
strcpy(remote, "");
UserDefDaysOfWeek = 0;
checkmode = 0;
- if (Timer)
- {
- timer = Timer;
- newtimer = *timer;
- event = Event;
- flags = Timer->Flags();
- day = Timer->Day();
- weekdays = Timer->WeekDays();
-
- start = Timer->Start();
- stop = Timer->Stop();
- priority = Timer->Priority();
- lifetime = Timer->Lifetime();
- strcpy(file, Timer->File());
- channel = Timer->Channel()->Number();
+ if (Timer) {
+ timer = Timer;
+ newtimer = *timer;
+ event = Event;
+ flags = Timer->Flags();
+ day = Timer->Day();
+ weekdays = Timer->WeekDays();
+
+ start = Timer->Start();
+ stop = Timer->Stop();
+ priority = Timer->Priority();
+ lifetime = Timer->Lifetime();
+ strcpy(file, Timer->File());
+ channel = Timer->Channel()->Number();
#ifdef USE_PINPLUGIN
- fskProtection = Timer->FskProtection();
+ fskProtection = Timer->FskProtection();
#endif
- if (Timer->Remote())
- strcpy(remote, Timer->Remote());
- if (forcechannel)
- channel = forcechannel->Number();
- SplitFile();
-
- addIfConfirmed = New;
- Set();
- SetHelp(addIfConfirmed?NULL:trVDR("Button$Delete"), NULL, NULL, NULL);
+ if (Timer->Remote())
+ strcpy(remote, Timer->Remote());
+ if (forcechannel)
+ channel = forcechannel->Number();
+ SplitFile();
+
+ addIfConfirmed = New;
+ Set();
+ SetHelp(addIfConfirmed ? NULL : trVDR("Button$Delete"), NULL, NULL, NULL);
}
}
void cMenuMyEditTimer::SplitFile()
{
- char* tmp = strrchr(file, '~');
- if (tmp) // split file in real file and directory
- {
- if (event && !isempty(event->ShortText()))
- {
- cString eventFile = cString::sprintf("%s~%s", event->Title(), event->ShortText());
- char* tmp2 = strstr(file, eventFile);
- if (tmp2) // file contains title and subtitle
- {
- if (tmp2 > file)
- {
- *(tmp2-1) = 0;
- strcpy(directory, file);
- strcpy(file, tmp2);
- }
- else
- *directory = 0;
- }
- else
- {
- *tmp = 0;
- strcpy(directory, file);
- strcpy(file, tmp+1);
- }
- }
- else
- {
- *tmp = 0;
- strcpy(directory, file);
- strcpy(file, tmp+1);
- }
- }
- else
- *directory = 0;
+ char* tmp = strrchr(file, '~');
+ if (tmp) { // split file in real file and directory
+ if (event && !isempty(event->ShortText())) {
+ cString eventFile = cString::sprintf("%s~%s", event->Title(), event->ShortText());
+ char* tmp2 = strstr(file, eventFile);
+ if (tmp2) { // file contains title and subtitle
+ if (tmp2 > file) {
+ *(tmp2 - 1) = 0;
+ strcpy(directory, file);
+ strcpy(file, tmp2);
+ } else
+ *directory = 0;
+ } else {
+ *tmp = 0;
+ strcpy(directory, file);
+ strcpy(file, tmp + 1);
+ }
+ } else {
+ *tmp = 0;
+ strcpy(directory, file);
+ strcpy(file, tmp + 1);
+ }
+ } else
+ *directory = 0;
}
void cMenuMyEditTimer::Set()
@@ -125,15 +114,15 @@ void cMenuMyEditTimer::Set()
cSearchExt* search = TriggeredFromSearchTimer(timer);
- Add(new cMenuEditStrItem( trVDR("File"), file, MaxFileName, trVDR(FileNameChars)));
- Add(new cMenuEditStrItem( tr("Directory"), directory, MaxFileName, tr(AllowedChars)));
- Add(new cMenuEditBitItem( trVDR("Active"), &flags, tfActive));
+ Add(new cMenuEditStrItem(trVDR("File"), file, MaxFileName, trVDR(FileNameChars)));
+ Add(new cMenuEditStrItem(tr("Directory"), directory, MaxFileName, tr(AllowedChars)));
+ Add(new cMenuEditBitItem(trVDR("Active"), &flags, tfActive));
#ifdef USE_PINPLUGIN
if (cOsd::pinValid || !fskProtection) Add(new cMenuEditChanItem(tr("Channel"), &channel));
else {
- LOCK_CHANNELS_READ;
- cString buf = cString::sprintf("%s\t%s", tr("Channel"), Channels->GetByNumber(channel)->Name());
- Add(new cOsdItem(buf));
+ LOCK_CHANNELS_READ;
+ cString buf = cString::sprintf("%s\t%s", tr("Channel"), Channels->GetByNumber(channel)->Name());
+ Add(new cOsdItem(buf));
}
#else
Add(new cMenuEditChanItem(trVDR("Channel"), &channel));
@@ -141,61 +130,55 @@ void cMenuMyEditTimer::Set()
Add(new cMenuEditDateItem(trVDR("Day"), &day, &weekdays));
if (!IsSingleEvent())
- Add(new cMenuEditDateItem(trVDR("First day"), &day));
+ Add(new cMenuEditDateItem(trVDR("First day"), &day));
Add(new cMenuEditTimeItem(trVDR("Start"), &start));
Add(new cMenuEditTimeItem(trVDR("Stop"), &stop));
- Add(new cMenuEditBitItem( trVDR("VPS"), &flags, tfVps));
- Add(new cMenuEditIntItem( trVDR("Priority"), &priority, 0, MAXPRIORITY));
- Add(new cMenuEditIntItem( trVDR("Lifetime"), &lifetime, 0, MAXLIFETIME));
+ Add(new cMenuEditBitItem(trVDR("VPS"), &flags, tfVps));
+ Add(new cMenuEditIntItem(trVDR("Priority"), &priority, 0, MAXPRIORITY));
+ Add(new cMenuEditIntItem(trVDR("Lifetime"), &lifetime, 0, MAXLIFETIME));
#ifdef USE_PINPLUGIN
- if (cOsd::pinValid || !fskProtection) Add(new cMenuEditBoolItem(tr("Childlock"),&fskProtection));
+ if (cOsd::pinValid || !fskProtection) Add(new cMenuEditBoolItem(tr("Childlock"), &fskProtection));
else {
- cString buf = cString::sprintf("%s\t%s", tr("Childlock"), fskProtection ? trVDR("yes") : trVDR("no"));
- Add(new cOsdItem(buf));
+ cString buf = cString::sprintf("%s\t%s", tr("Childlock"), fskProtection ? trVDR("yes") : trVDR("no"));
+ Add(new cOsdItem(buf));
}
#endif
- if (GetSVDRPServerNames(&svdrpServerNames)) {
- svdrpServerNames.Sort(true);
- svdrpServerNames.Insert(strdup(""));
- Add(new cMenuEditStrlItem(tr("Record on"), remote, sizeof(remote), &svdrpServerNames));
- }
- if (search)
- {
- cMenuEditStrItem* searchtimerItem = new cMenuEditStrItem( tr("Search timer"), search->search, MaxFileName, tr(AllowedChars));
- searchtimerItem->SetSelectable(false);
- Add(searchtimerItem);
+ if (GetSVDRPServerNames(&svdrpServerNames)) {
+ svdrpServerNames.Sort(true);
+ svdrpServerNames.Insert(strdup(""));
+ Add(new cMenuEditStrlItem(tr("Record on"), remote, sizeof(remote), &svdrpServerNames));
}
- else if (IsSingleEvent() && event)
- {
- {
- LOCK_CHANNELS_READ;
- checkmode = DefTimerCheckModes.GetMode(Channels->GetByNumber(channel));
- }
- char* checkmodeAux = GetAuxValue(timer, "update");
- if (checkmodeAux)
- {
- checkmode = atoi(checkmodeAux);
- free(checkmodeAux);
- }
- Add(new cMenuEditStraItem(tr("Timer check"), &checkmode, 3, CheckModes));
+ if (search) {
+ cMenuEditStrItem* searchtimerItem = new cMenuEditStrItem(tr("Search timer"), search->search, MaxFileName, tr(AllowedChars));
+ searchtimerItem->SetSelectable(false);
+ Add(searchtimerItem);
+ } else if (IsSingleEvent() && event) {
+ {
+ LOCK_CHANNELS_READ;
+ checkmode = DefTimerCheckModes.GetMode(Channels->GetByNumber(channel));
+ }
+ char* checkmodeAux = GetAuxValue(timer, "update");
+ if (checkmodeAux) {
+ checkmode = atoi(checkmodeAux);
+ free(checkmodeAux);
+ }
+ Add(new cMenuEditStraItem(tr("Timer check"), &checkmode, 3, CheckModes));
}
int deviceNr = gl_recStatusMonitor->TimerRecDevice(timer);
- if (deviceNr > 0)
- {
- cOsdItem* pInfoItem = new cOsdItem("");
- pInfoItem->SetSelectable(false);
- Add(pInfoItem);
- cString info = cString::sprintf("%s: %d/%d", tr("recording with device"), deviceNr, cDevice::NumDevices());
- pInfoItem = new cOsdItem(info);
- pInfoItem->SetSelectable(false);
- Add(pInfoItem);
+ if (deviceNr > 0) {
+ cOsdItem* pInfoItem = new cOsdItem("");
+ pInfoItem->SetSelectable(false);
+ Add(pInfoItem);
+ cString info = cString::sprintf("%s: %d/%d", tr("recording with device"), deviceNr, cDevice::NumDevices());
+ pInfoItem = new cOsdItem(info);
+ pInfoItem->SetSelectable(false);
+ Add(pInfoItem);
}
- if (current > -1)
- {
- SetCurrent(Get(current));
+ if (current > -1) {
+ SetCurrent(Get(current));
RefreshCurrent();
}
Display();
@@ -203,31 +186,28 @@ void cMenuMyEditTimer::Set()
cMenuMyEditTimer::~cMenuMyEditTimer()
{
- if (timer && addIfConfirmed)
- delete timer; // apparently it wasn't confirmed
+ if (timer && addIfConfirmed)
+ delete timer; // apparently it wasn't confirmed
}
void cMenuMyEditTimer::HandleSubtitle()
{
const char* ItemText = Get(Current())->Text();
if (strstr(ItemText, trVDR("File")) != ItemText)
- return;
+ return;
if (InEditMode(ItemText, trVDR("File"), file))
- return;
+ return;
if (!event || (event && !event->ShortText()))
- return;
+ return;
char* tmp = strchr(file, '~');
- if (tmp)
- {
- *tmp = 0;
- SetHelp(addIfConfirmed?NULL:trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), tr("Button$With subtitle"));
- }
- else
- {
- strcat(file, "~");
- strncat(file, event->ShortText(), MaxFileName - strlen(file) - 1);
- SetHelp(addIfConfirmed?NULL:trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), tr("Button$Without subtitle"));
+ if (tmp) {
+ *tmp = 0;
+ SetHelp(addIfConfirmed ? NULL : trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), tr("Button$With subtitle"));
+ } else {
+ strcat(file, "~");
+ strncat(file, event->ShortText(), MaxFileName - strlen(file) - 1);
+ SetHelp(addIfConfirmed ? NULL : trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), tr("Button$Without subtitle"));
}
RefreshCurrent();
Display();
@@ -235,7 +215,7 @@ void cMenuMyEditTimer::HandleSubtitle()
bool cMenuMyEditTimer::IsSingleEvent(void) const
{
- return !weekdays;
+ return !weekdays;
}
eOSState cMenuMyEditTimer::DeleteTimer()
@@ -244,32 +224,30 @@ eOSState cMenuMyEditTimer::DeleteTimer()
LOCK_TIMERS_WRITE;
Timers->SetExplicitModify();
if (timer && !addIfConfirmed) {
- if (Interface->Confirm(trVDR("Delete timer?"))) {
- if (timer->Recording()) {
- if (Interface->Confirm(trVDR("Timer still recording - really delete?"))) {
- if (!timer->Remote()) {
- timer->Skip();
- cRecordControls::Process(Timers, time(NULL));
- }
- }
- else
- timer = NULL;
- }
- if (timer) {
- if (!HandleRemoteTimerModifications(NULL, timer))
- {
- LogFile.Log(2,"HandleRemoteTimerModifications failed");
- return osContinue;
- }
- LogFile.iSysLog("deleting timer %s", *timer->ToDescr());
- Timers->Del(timer);
-
- gl_timerStatusMonitor->SetConflictCheckAdvised();
- Timers->SetModified();
- return osBack;
+ if (Interface->Confirm(trVDR("Delete timer?"))) {
+ if (timer->Recording()) {
+ if (Interface->Confirm(trVDR("Timer still recording - really delete?"))) {
+ if (!timer->Remote()) {
+ timer->Skip();
+ cRecordControls::Process(Timers, time(NULL));
+ }
+ } else
+ timer = NULL;
+ }
+ if (timer) {
+ if (!HandleRemoteTimerModifications(NULL, timer)) {
+ LogFile.Log(2, "HandleRemoteTimerModifications failed");
+ return osContinue;
+ }
+ LogFile.iSysLog("deleting timer %s", *timer->ToDescr());
+ Timers->Del(timer);
+
+ gl_timerStatusMonitor->SetConflictCheckAdvised();
+ Timers->SetModified();
+ return osBack;
+ }
}
}
- }
return osContinue;
}
@@ -279,255 +257,225 @@ eOSState cMenuMyEditTimer::ProcessKey(eKeys Key)
eOSState state = cOsdMenu::ProcessKey(Key);
- if (bWasSingleEvent != IsSingleEvent())
- {
- Set();
- Display();
+ if (bWasSingleEvent != IsSingleEvent()) {
+ Set();
+ Display();
}
int iOnDirectoryItem = 0;
int iOnFileItem = 0;
int iOnDayItem = 0;
const char* ItemText = Get(Current())->Text();
- if (!HasSubMenu() && ItemText && strlen(ItemText)>0)
- {
- if (strstr(ItemText, trVDR("Day")) == ItemText)
- {
- if (!IsSingleEvent())
- {
- SetHelp(trVDR("Button$Edit"));
- iOnDayItem = 1;
- }
- else
- SetHelp(addIfConfirmed?NULL:trVDR("Button$Delete"), NULL, NULL, NULL);
- }
- else if (strstr(ItemText, tr("Directory")) == ItemText)
- {
- if (!InEditMode(ItemText, tr("Directory"), directory))
- SetHelp(addIfConfirmed?NULL:trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), tr("Button$Select"));
- iOnDirectoryItem = 1;
- }
- else if (strstr(ItemText, trVDR("File")) == ItemText)
- {
- if (!InEditMode(ItemText, trVDR("File"), file))
- {
- if (event && event->ShortText())
- {
- if (strchr(file, '~'))
- SetHelp(addIfConfirmed?NULL:trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), tr("Button$Without subtitle"));
- else
- SetHelp(addIfConfirmed?NULL:trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), tr("Button$With subtitle"));
- }
- else
- SetHelp(addIfConfirmed?NULL:trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), NULL);
- }
- iOnFileItem = 1;
- }
- else
- SetHelp(addIfConfirmed?NULL:trVDR("Button$Delete"), NULL, NULL, NULL);
+ if (!HasSubMenu() && ItemText && strlen(ItemText) > 0) {
+ if (strstr(ItemText, trVDR("Day")) == ItemText) {
+ if (!IsSingleEvent()) {
+ SetHelp(trVDR("Button$Edit"));
+ iOnDayItem = 1;
+ } else
+ SetHelp(addIfConfirmed ? NULL : trVDR("Button$Delete"), NULL, NULL, NULL);
+ } else if (strstr(ItemText, tr("Directory")) == ItemText) {
+ if (!InEditMode(ItemText, tr("Directory"), directory))
+ SetHelp(addIfConfirmed ? NULL : trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), tr("Button$Select"));
+ iOnDirectoryItem = 1;
+ } else if (strstr(ItemText, trVDR("File")) == ItemText) {
+ if (!InEditMode(ItemText, trVDR("File"), file)) {
+ if (event && event->ShortText()) {
+ if (strchr(file, '~'))
+ SetHelp(addIfConfirmed ? NULL : trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), tr("Button$Without subtitle"));
+ else
+ SetHelp(addIfConfirmed ? NULL : trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), tr("Button$With subtitle"));
+ } else
+ SetHelp(addIfConfirmed ? NULL : trVDR("Button$Delete"), NULL, trVDR("Button$Reset"), NULL);
+ }
+ iOnFileItem = 1;
+ } else
+ SetHelp(addIfConfirmed ? NULL : trVDR("Button$Delete"), NULL, NULL, NULL);
}
if ((Key == kYellow) && ((iOnDirectoryItem && !InEditMode(ItemText, tr("Directory"), directory)) ||
- (iOnFileItem && !InEditMode(ItemText, trVDR("File"), file))))
- {
- if (iOnDirectoryItem)
- strcpy(directory, "");
- if (iOnFileItem && event)
- strn0cpy(file, event->Title(),sizeof(file));
- RefreshCurrent();
- Display();
+ (iOnFileItem && !InEditMode(ItemText, trVDR("File"), file)))) {
+ if (iOnDirectoryItem)
+ strcpy(directory, "");
+ if (iOnFileItem && event)
+ strn0cpy(file, event->Title(), sizeof(file));
+ RefreshCurrent();
+ Display();
}
- if (state == osUnknown)
- {
- switch (Key)
- {
- case kOk:
- {
- string fullaux = "";
- string aux = "";
- if (timer && timer->Aux())
- fullaux = timer->Aux();
-
- if (event && IsSingleEvent())
- {
- time_t startTime = 0, stopTime = 0;;
- int begin = cTimer::TimeToInt(start); // seconds from midnight
- int length = cTimer::TimeToInt(stop) - begin;
- if (length < 0)
- length += SECSINDAY;
- startTime = cTimer::SetTime(day, begin);
- stopTime = startTime + length;
- // calculate margins
- int bstart = event->StartTime() - startTime;
- int bstop = stopTime - event->EndTime();
-
- char* epgsearchaux = GetAuxValue(timer, "epgsearch");
- if (epgsearchaux)
- {
- aux = epgsearchaux;
- free(epgsearchaux);
- }
- LOCK_CHANNELS_READ;
- const cChannel *ch = Channels->GetByNumber(channel);
- if (!ch)
- {
- ERROR(tr("*** Invalid Channel ***"));
- break;
- }
-
- aux = UpdateAuxValue(aux, "channel", NumToString(ch->Number()) + " - " + CHANNELNAME(ch));
- aux = UpdateAuxValue(aux, "update", checkmode);
- aux = UpdateAuxValue(aux, "eventid", event->EventID());
- aux = UpdateAuxValue(aux, "bstart", bstart);
- aux = UpdateAuxValue(aux, "bstop", bstop);
- if (addIfConfirmed) // do not update start and stop time in aux if this is an existing timer, we need this to detect manual editing
- {
- aux = UpdateAuxValue(aux, "start", startTime);
- aux = UpdateAuxValue(aux, "stop", stopTime);
- }
- fullaux = UpdateAuxValue(fullaux, "epgsearch", aux);
- }
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk: {
+ string fullaux = "";
+ string aux = "";
+ if (timer && timer->Aux())
+ fullaux = timer->Aux();
+
+ if (event && IsSingleEvent()) {
+ time_t startTime = 0, stopTime = 0;;
+ int begin = cTimer::TimeToInt(start); // seconds from midnight
+ int length = cTimer::TimeToInt(stop) - begin;
+ if (length < 0)
+ length += SECSINDAY;
+ startTime = cTimer::SetTime(day, begin);
+ stopTime = startTime + length;
+ // calculate margins
+ int bstart = event->StartTime() - startTime;
+ int bstop = stopTime - event->EndTime();
+
+ char* epgsearchaux = GetAuxValue(timer, "epgsearch");
+ if (epgsearchaux) {
+ aux = epgsearchaux;
+ free(epgsearchaux);
+ }
+ LOCK_CHANNELS_READ;
+ const cChannel *ch = Channels->GetByNumber(channel);
+ if (!ch) {
+ ERROR(tr("*** Invalid Channel ***"));
+ break;
+ }
+
+ aux = UpdateAuxValue(aux, "channel", NumToString(ch->Number()) + " - " + CHANNELNAME(ch));
+ aux = UpdateAuxValue(aux, "update", checkmode);
+ aux = UpdateAuxValue(aux, "eventid", event->EventID());
+ aux = UpdateAuxValue(aux, "bstart", bstart);
+ aux = UpdateAuxValue(aux, "bstop", bstop);
+ if (addIfConfirmed) { // do not update start and stop time in aux if this is an existing timer, we need this to detect manual editing
+ aux = UpdateAuxValue(aux, "start", startTime);
+ aux = UpdateAuxValue(aux, "stop", stopTime);
+ }
+ fullaux = UpdateAuxValue(fullaux, "epgsearch", aux);
+ }
#ifdef USE_PINPLUGIN
- aux = "";
- aux = UpdateAuxValue(aux, "protected", fskProtection ? "yes" : "no");
- fullaux = UpdateAuxValue(fullaux, "pin-plugin", aux);
+ aux = "";
+ aux = UpdateAuxValue(aux, "protected", fskProtection ? "yes" : "no");
+ fullaux = UpdateAuxValue(fullaux, "pin-plugin", aux);
#endif
- char* tmpFile = strdup(file);
- strreplace(tmpFile, ':', '|');
- char* tmpDir = strdup(directory);
- strreplace(tmpDir, ':', '|');
-
- if (timer)
- {
- LOCK_TIMERS_WRITE;
- if (!addIfConfirmed && !Timers->Contains(timer))
- {
- if (cTimer *t = Timers->GetById(timer->Id(), timer->Remote()))
- timer = t;
- else
- {
- ERROR(tr("Timer has been deleted"));
- break;
- }
- }
- LOCK_CHANNELS_READ;
- const cChannel *ch = Channels->GetByNumber(channel);
- if (!ch)
- {
- ERROR(tr("*** Invalid Channel ***"));
- break;
- }
- if (strlen(tmpFile) == 0)
- {
- free(tmpFile);
- tmpFile = strdup(CHANNELNAME(ch));
- }
- cString cmdbuf;
- cmdbuf = cString::sprintf("%d:%d:%s:%04d:%04d:%d:%d:%s%s%s:%s",
- flags,
- channel,
- PRINTDAY(day, weekdays, true),
- start,
- stop,
- priority,
- lifetime,
- strlen(tmpDir)>0?tmpDir:"",
- (strlen(tmpDir)>0 && strlen(tmpFile)>0)?"~":"",
- tmpFile,
- fullaux.c_str());
-
- newtimer.Parse(cmdbuf);
-
+ char* tmpFile = strdup(file);
+ strreplace(tmpFile, ':', '|');
+ char* tmpDir = strdup(directory);
+ strreplace(tmpDir, ':', '|');
+
+ if (timer) {
+ LOCK_TIMERS_WRITE;
+ if (!addIfConfirmed && !Timers->Contains(timer)) {
+ if (cTimer *t = Timers->GetById(timer->Id(), timer->Remote()))
+ timer = t;
+ else {
+ ERROR(tr("Timer has been deleted"));
+ break;
+ }
+ }
+ LOCK_CHANNELS_READ;
+ const cChannel *ch = Channels->GetByNumber(channel);
+ if (!ch) {
+ ERROR(tr("*** Invalid Channel ***"));
+ break;
+ }
+ if (strlen(tmpFile) == 0) {
free(tmpFile);
- free(tmpDir);
-
- newtimer.SetRemote(*remote ? remote : NULL);
- if (addIfConfirmed) {
- *timer = newtimer;
- Timers->Add(timer);
- if (!HandleRemoteTimerModifications(timer)) {
- Timers->Del(timer);
- ERROR(tr("Epgsearch: RemoteTimerModifications failed"));
- return osContinue;
- }
+ tmpFile = strdup(CHANNELNAME(ch));
+ }
+ cString cmdbuf;
+ cmdbuf = cString::sprintf("%d:%d:%s:%04d:%04d:%d:%d:%s%s%s:%s",
+ flags,
+ channel,
+ PRINTDAY(day, weekdays, true),
+ start,
+ stop,
+ priority,
+ lifetime,
+ strlen(tmpDir) > 0 ? tmpDir : "",
+ (strlen(tmpDir) > 0 && strlen(tmpFile) > 0) ? "~" : "",
+ tmpFile,
+ fullaux.c_str());
+
+ newtimer.Parse(cmdbuf);
+
+ free(tmpFile);
+ free(tmpDir);
+
+ newtimer.SetRemote(*remote ? remote : NULL);
+ if (addIfConfirmed) {
+ *timer = newtimer;
+ Timers->Add(timer);
+ if (!HandleRemoteTimerModifications(timer)) {
+ Timers->Del(timer);
+ ERROR(tr("Epgsearch: RemoteTimerModifications failed"));
+ return osContinue;
}
- else {
- if (!HandleRemoteTimerModifications(&newtimer, timer)) {
- return osContinue;
- }
- if (timer->Local() && timer->Recording() && newtimer.Remote())
- cRecordControls::Stop(timer);
- *timer = newtimer;
- }
- LOCK_SCHEDULES_READ;
- timer->SetEventFromSchedule(Schedules);
- timer->Matches();
- gl_timerStatusMonitor->SetConflictCheckAdvised();
- addIfConfirmed = false;
} else {
- free(tmpFile);
- free(tmpDir);
- }
- }
- return osBack;
- case kRed:
- if (HasSubMenu())
- return osContinue;
- else
- if (iOnDayItem)
- return AddSubMenu(new cMenuEditDaysOfWeek(&weekdays,1,false));
- else
- return DeleteTimer();
- break;
- case kGreen:
- case kYellow:
- return osContinue;
- case kBlue:
- if (HasSubMenu())
- return osContinue;
- if (iOnDirectoryItem && !InEditMode(ItemText, tr("Directory"), directory))
- state = AddSubMenu(new cMenuDirSelect(directory));
- if (iOnFileItem)
- {
- HandleSubtitle();
- return osContinue;
- }
- break;
- default: break;
- }
+ if (!HandleRemoteTimerModifications(&newtimer, timer)) {
+ return osContinue;
+ }
+ if (timer->Local() && timer->Recording() && newtimer.Remote())
+ cRecordControls::Stop(timer);
+ *timer = newtimer;
+ }
+ LOCK_SCHEDULES_READ;
+ timer->SetEventFromSchedule(Schedules);
+ timer->Matches();
+ gl_timerStatusMonitor->SetConflictCheckAdvised();
+ addIfConfirmed = false;
+ } else {
+ free(tmpFile);
+ free(tmpDir);
+ }
+ }
+ return osBack;
+ case kRed:
+ if (HasSubMenu())
+ return osContinue;
+ else if (iOnDayItem)
+ return AddSubMenu(new cMenuEditDaysOfWeek(&weekdays, 1, false));
+ else
+ return DeleteTimer();
+ break;
+ case kGreen:
+ case kYellow:
+ return osContinue;
+ case kBlue:
+ if (HasSubMenu())
+ return osContinue;
+ if (iOnDirectoryItem && !InEditMode(ItemText, tr("Directory"), directory))
+ state = AddSubMenu(new cMenuDirSelect(directory));
+ if (iOnFileItem) {
+ HandleSubtitle();
+ return osContinue;
+ }
+ break;
+ default:
+ break;
+ }
}
- if (Key != kNone && !HasSubMenu())
- {
- if (iOnDirectoryItem && !InEditMode(ItemText, tr("Directory"), directory))
- ReplaceDirVars();
+ if (Key != kNone && !HasSubMenu()) {
+ if (iOnDirectoryItem && !InEditMode(ItemText, tr("Directory"), directory))
+ ReplaceDirVars();
}
return state;
}
void cMenuMyEditTimer::ReplaceDirVars()
{
- if (!strchr(directory,'%') || !event)
- return;
+ if (!strchr(directory, '%') || !event)
+ return;
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
- *directory = 0;
- if (varExpr.DependsOnVar("%title%", event) || varExpr.DependsOnVar("%subtitle%", event))
- {
- strcpy(file, directory);
- *directory = 0;
- SplitFile();
+ *directory = 0;
+ if (varExpr.DependsOnVar("%title%", event) || varExpr.DependsOnVar("%subtitle%", event)) {
+ strcpy(file, directory);
+ *directory = 0;
+ SplitFile();
}
RefreshCurrent();
// update title too
if (Current() > 0)
- Get(Current()-1)->Set();
+ Get(Current() - 1)->Set();
Display();
return;
}
diff --git a/menu_myedittimer.h b/menu_myedittimer.h
index ce39270..49f9066 100644
--- a/menu_myedittimer.h
+++ b/menu_myedittimer.h
@@ -29,42 +29,43 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include <vdr/svdrp.h>
// --- cMenuMyEditTimer --------------------------------------------------------
-class cMenuMyEditTimer : public cOsdMenu {
+class cMenuMyEditTimer : public cOsdMenu
+{
private:
- cTimer *timer;
- cTimer newtimer;
- const cEvent* event;
- int channel;
- bool addIfConfirmed;
- int UserDefDaysOfWeek;
- cMenuEditStrItem* m_DirItem;
+ cTimer *timer;
+ cTimer newtimer;
+ const cEvent* event;
+ int channel;
+ bool addIfConfirmed;
+ int UserDefDaysOfWeek;
+ cMenuEditStrItem* m_DirItem;
- uint flags;
- time_t day;
- int weekdays;
- int start;
- int stop;
- int priority;
- int lifetime;
- char file[MaxFileName];
- char directory[MaxFileName];
+ uint flags;
+ time_t day;
+ int weekdays;
+ int start;
+ int stop;
+ int priority;
+ int lifetime;
+ char file[MaxFileName];
+ char directory[MaxFileName];
#ifdef USE_PINPLUGIN
- int fskProtection;
+ int fskProtection;
#endif
- cStringList svdrpServerNames;
- char remote[HOST_NAME_MAX];
- int checkmode;
+ cStringList svdrpServerNames;
+ char remote[HOST_NAME_MAX];
+ int checkmode;
public:
- cMenuMyEditTimer(cTimer *Timer, bool New, const cEvent* event, const cChannel* forcechannel=NULL);
- virtual ~cMenuMyEditTimer();
- virtual eOSState ProcessKey(eKeys Key);
- void HandleSubtitle();
- void Set();
- void ReplaceDirVars();
- bool IsSingleEvent(void) const;
- void SplitFile();
- eOSState DeleteTimer();
+ cMenuMyEditTimer(cTimer *Timer, bool New, const cEvent* event, const cChannel* forcechannel = NULL);
+ virtual ~cMenuMyEditTimer();
+ virtual eOSState ProcessKey(eKeys Key);
+ void HandleSubtitle();
+ void Set();
+ void ReplaceDirVars();
+ bool IsSingleEvent(void) const;
+ void SplitFile();
+ eOSState DeleteTimer();
- static const char* CheckModes[3];
+ static const char* CheckModes[3];
};
#endif
diff --git a/menu_quicksearch.c b/menu_quicksearch.c
index cceaefa..e9309b5 100644
--- a/menu_quicksearch.c
+++ b/menu_quicksearch.c
@@ -35,7 +35,7 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
// --- cMenuQuickSearch --------------------------------------------------------
cMenuQuickSearch::cMenuQuickSearch(cSearchExt* Quicksearch)
-:cMenuEditSearchExt(Quicksearch, true, true)
+ : cMenuEditSearchExt(Quicksearch, true, true)
{
editmode = QUICKSEARCHSIMPLE;
Set();
@@ -47,84 +47,72 @@ void cMenuQuickSearch::Set()
int current = Current();
Clear();
- Add(new cMenuEditStrItem( tr("Search term"), data.search, sizeof(data.search), tr(AllowedChars)));
- if (editmode == QUICKSEARCHEXT)
- {
- Add(new cMenuEditStraItem(tr("Search mode"), &data.mode, 6, SearchModes));
- if (data.mode == 5) // fuzzy
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Tolerance")), &data.fuzzyTolerance, 1, 9));
+ Add(new cMenuEditStrItem(tr("Search term"), data.search, sizeof(data.search), tr(AllowedChars)));
+ if (editmode == QUICKSEARCHEXT) {
+ Add(new cMenuEditStraItem(tr("Search mode"), &data.mode, 6, SearchModes));
+ if (data.mode == 5) // fuzzy
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Tolerance")), &data.fuzzyTolerance, 1, 9));
- Add(new cMenuEditBoolItem( tr("Match case"), &data.useCase, trVDR("no"), trVDR("yes")));
- Add(new cMenuEditBoolItem( tr("Use title"), &data.useTitle, trVDR("no"), trVDR("yes")));
- Add(new cMenuEditBoolItem( tr("Use subtitle"), &data.useSubtitle, trVDR("no"), trVDR("yes")));
- Add(new cMenuEditBoolItem( tr("Use description"), &data.useDescription, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Match case"), &data.useCase, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Use title"), &data.useTitle, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Use subtitle"), &data.useSubtitle, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Use description"), &data.useDescription, trVDR("no"), trVDR("yes")));
- // show Categories only if we have them
- if (SearchExtCats.Count() > 0)
- {
- Add(new cMenuEditBoolItem( tr("Use extended EPG info"), &data.useExtEPGInfo, trVDR("no"), trVDR("yes")));
- if (data.useExtEPGInfo)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- Add(new cMenuEditStrItem( IndentMenuItem(SearchExtCat->menuname), data.catvalues[index], MaxFileName, tr(AllowedChars)));
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- }
- }
+ // show Categories only if we have them
+ if (SearchExtCats.Count() > 0) {
+ Add(new cMenuEditBoolItem(tr("Use extended EPG info"), &data.useExtEPGInfo, trVDR("no"), trVDR("yes")));
+ if (data.useExtEPGInfo) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ Add(new cMenuEditStrItem(IndentMenuItem(SearchExtCat->menuname), data.catvalues[index], MaxFileName, tr(AllowedChars)));
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+ }
+ }
- Add(new cMenuEditStraItem(tr("Use channel"), &data.useChannel, 4, UseChannelSel));
- if (data.useChannel==1)
- {
- Add(new cMenuEditChanItem(tr(" from channel"), &channelMin));
- Add(new cMenuEditChanItem(tr(" to channel"), &channelMax));
- }
- if (data.useChannel==2)
- {
- // create the char array for the menu display
- if (menuitemsChGr) delete [] menuitemsChGr;
- menuitemsChGr = ChannelGroups.CreateMenuitemsList();
- int oldchannelGroupNr = channelGroupNr;
- channelGroupNr = ChannelGroups.GetIndex(channelGroupName);
- if (channelGroupNr == -1)
- {
- if (oldchannelGroupNr > 0 && oldchannelGroupNr <= ChannelGroups.Count()) // perhaps its name was changed
- channelGroupNr = oldchannelGroupNr;
- else
- channelGroupNr = 0; // no selection
- }
- else
- channelGroupNr++;
- Add(new cMenuEditStraItem(IndentMenuItem(tr("Channel group")), &channelGroupNr, ChannelGroups.Count()+1, menuitemsChGr));
- }
+ Add(new cMenuEditStraItem(tr("Use channel"), &data.useChannel, 4, UseChannelSel));
+ if (data.useChannel == 1) {
+ Add(new cMenuEditChanItem(tr(" from channel"), &channelMin));
+ Add(new cMenuEditChanItem(tr(" to channel"), &channelMax));
+ }
+ if (data.useChannel == 2) {
+ // create the char array for the menu display
+ if (menuitemsChGr) delete [] menuitemsChGr;
+ menuitemsChGr = ChannelGroups.CreateMenuitemsList();
+ int oldchannelGroupNr = channelGroupNr;
+ channelGroupNr = ChannelGroups.GetIndex(channelGroupName);
+ if (channelGroupNr == -1) {
+ if (oldchannelGroupNr > 0 && oldchannelGroupNr <= ChannelGroups.Count()) // perhaps its name was changed
+ channelGroupNr = oldchannelGroupNr;
+ else
+ channelGroupNr = 0; // no selection
+ } else
+ channelGroupNr++;
+ Add(new cMenuEditStraItem(IndentMenuItem(tr("Channel group")), &channelGroupNr, ChannelGroups.Count() + 1, menuitemsChGr));
+ }
- Add(new cMenuEditBoolItem( tr("Use time"), &data.useTime, trVDR("no"), trVDR("yes")));
- if (data.useTime == true)
- {
- Add(new cMenuEditTimeItem(tr(" Start after"), &data.startTime));
- Add(new cMenuEditTimeItem(tr(" Start before"), &data.stopTime));
- }
- Add(new cMenuEditBoolItem( tr("Use duration"), &data.useDuration, trVDR("no"), trVDR("yes")));
- if (data.useDuration == true)
- {
- Add(new cMenuEditTimeItem(tr(" Min. duration"), &data.minDuration));
- Add(new cMenuEditTimeItem(tr(" Max. duration"), &data.maxDuration));
- }
- Add(new cMenuEditBoolItem( tr("Use day of week"), &data.useDayOfWeek, trVDR("no"), trVDR("yes")));
- if (data.useDayOfWeek)
- {
- if (data.DayOfWeek < 0)
- {
- UserDefDayOfWeek = data.DayOfWeek;
- data.DayOfWeek = 7;
- }
- Add(new cMenuEditStraItem(IndentMenuItem(tr("Day of week")), &data.DayOfWeek, 8, DaysOfWeek));
- }
- Add(new cMenuEditStraItem(tr("Use blacklists"), &data.blacklistMode, 3, BlacklistModes));
+ Add(new cMenuEditBoolItem(tr("Use time"), &data.useTime, trVDR("no"), trVDR("yes")));
+ if (data.useTime == true) {
+ Add(new cMenuEditTimeItem(tr(" Start after"), &data.startTime));
+ Add(new cMenuEditTimeItem(tr(" Start before"), &data.stopTime));
+ }
+ Add(new cMenuEditBoolItem(tr("Use duration"), &data.useDuration, trVDR("no"), trVDR("yes")));
+ if (data.useDuration == true) {
+ Add(new cMenuEditTimeItem(tr(" Min. duration"), &data.minDuration));
+ Add(new cMenuEditTimeItem(tr(" Max. duration"), &data.maxDuration));
+ }
+ Add(new cMenuEditBoolItem(tr("Use day of week"), &data.useDayOfWeek, trVDR("no"), trVDR("yes")));
+ if (data.useDayOfWeek) {
+ if (data.DayOfWeek < 0) {
+ UserDefDayOfWeek = data.DayOfWeek;
+ data.DayOfWeek = 7;
+ }
+ Add(new cMenuEditStraItem(IndentMenuItem(tr("Day of week")), &data.DayOfWeek, 8, DaysOfWeek));
+ }
+ Add(new cMenuEditStraItem(tr("Use blacklists"), &data.blacklistMode, 3, BlacklistModes));
}
SetCurrent(Get(current));
}
@@ -147,29 +135,26 @@ eOSState cMenuQuickSearch::ProcessKey(eKeys Key)
eOSState state = cOsdMenu::ProcessKey(Key);
if (iTemp_mode != data.mode ||
- iTemp_useTime != data.useTime ||
- iTemp_useChannel != data.useChannel ||
- iTemp_useDuration != data.useDuration ||
- iTemp_useDayOfWeek != data.useDayOfWeek ||
- iTemp_useExtEPGInfo != data.useExtEPGInfo ||
- iTemp_avoidRepeats != data.avoidRepeats ||
- iTemp_allowedRepeats != data.allowedRepeats ||
- iTemp_delAfterDays != data.delAfterDays ||
- iTemp_action != data.action)
- {
- Set();
- Display();
+ iTemp_useTime != data.useTime ||
+ iTemp_useChannel != data.useChannel ||
+ iTemp_useDuration != data.useDuration ||
+ iTemp_useDayOfWeek != data.useDayOfWeek ||
+ iTemp_useExtEPGInfo != data.useExtEPGInfo ||
+ iTemp_avoidRepeats != data.avoidRepeats ||
+ iTemp_allowedRepeats != data.allowedRepeats ||
+ iTemp_delAfterDays != data.delAfterDays ||
+ iTemp_action != data.action) {
+ Set();
+ Display();
}
const char* ItemText = Get(Current())->Text();
- if (!HasSubMenu())
- {
- if (strlen(ItemText)>0 && strstr(ItemText, tr(" from channel")) == ItemText && ((Key >= k0 && Key <= k9) || Key == kLeft || Key == kRight))
- {
- channelMax = channelMin;
- Set();
- Display();
- }
+ if (!HasSubMenu()) {
+ if (strlen(ItemText) > 0 && strstr(ItemText, tr(" from channel")) == ItemText && ((Key >= k0 && Key <= k9) || Key == kLeft || Key == kRight)) {
+ channelMax = channelMin;
+ Set();
+ Display();
+ }
}
int iOnUserDefDayItem = 0;
@@ -181,158 +166,133 @@ eOSState cMenuQuickSearch::ProcessKey(eKeys Key)
int iCatIndex = -1;
char* catname = NULL;
- if (!HasSubMenu() && strlen(ItemText)>0)
- {
- // check, if on an item of ext. EPG info
- int iOnExtCatItem = 0;
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- if (strstr(ItemText, IndentMenuItem(SearchExtCat->menuname)) == ItemText)
- {
- iOnExtCatItem = 1;
- if (SearchExtCat->nvalues > 0)
- iOnExtCatItemBrowsable = 1;
- iCatIndex = index;
- catname = SearchExtCat->menuname;
- break;
- }
- index++;
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- }
- if (strstr(ItemText, tr("Search term")) == ItemText)
- {
- if (!InEditMode(ItemText, tr("Search term"), data.search)) // show template for a new search
- {
- SetHelp(NULL, GREENLABEL, NULL, NULL);
- }
- }
- if (strstr(ItemText, IndentMenuItem(tr("Day of week"))) == ItemText)
- {
- if (data.DayOfWeek == 7)
- {
- SetHelp(trVDR("Button$Edit"), GREENLABEL);
- iOnUserDefDayItem = 1;
- }
- else
- SetHelp(NULL);
- }
- else if (strstr(ItemText, tr("Use channel")) == ItemText && data.useChannel == 2)
- {
- SetHelp(NULL, GREENLABEL, NULL, tr("Button$Setup"));
- iOnUseChannelGroups = 1;
- }
- else if (strstr(ItemText, IndentMenuItem(tr("Channel group"))) == ItemText)
- {
- SetHelp(NULL, GREENLABEL, NULL, tr("Button$Setup"));
- iOnChannelGroup = 1;
- }
- else if (strstr(ItemText, tr("Use blacklists")) == ItemText && data.blacklistMode == blacklistsSelection)
- {
- SetHelp(NULL, GREENLABEL, NULL, tr("Button$Setup"));
- iOnUseBlacklistsSelection = 1;
- }
- else if (iOnExtCatItem)
- {
- if (!InEditMode(ItemText, IndentMenuItem(catname), data.catvalues[iCatIndex]))
- SetHelp(NULL, GREENLABEL, NULL, iOnExtCatItemBrowsable?tr("Button$Select"):NULL);
- }
- else if (strstr(ItemText, tr("Search term")) != ItemText)
- SetHelp(NULL, GREENLABEL, NULL, NULL);
+ if (!HasSubMenu() && strlen(ItemText) > 0) {
+ // check, if on an item of ext. EPG info
+ int iOnExtCatItem = 0;
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ if (strstr(ItemText, IndentMenuItem(SearchExtCat->menuname)) == ItemText) {
+ iOnExtCatItem = 1;
+ if (SearchExtCat->nvalues > 0)
+ iOnExtCatItemBrowsable = 1;
+ iCatIndex = index;
+ catname = SearchExtCat->menuname;
+ break;
+ }
+ index++;
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ }
+ if (strstr(ItemText, tr("Search term")) == ItemText) {
+ if (!InEditMode(ItemText, tr("Search term"), data.search)) { // show template for a new search
+ SetHelp(NULL, GREENLABEL, NULL, NULL);
+ }
+ }
+ if (strstr(ItemText, IndentMenuItem(tr("Day of week"))) == ItemText) {
+ if (data.DayOfWeek == 7) {
+ SetHelp(trVDR("Button$Edit"), GREENLABEL);
+ iOnUserDefDayItem = 1;
+ } else
+ SetHelp(NULL);
+ } else if (strstr(ItemText, tr("Use channel")) == ItemText && data.useChannel == 2) {
+ SetHelp(NULL, GREENLABEL, NULL, tr("Button$Setup"));
+ iOnUseChannelGroups = 1;
+ } else if (strstr(ItemText, IndentMenuItem(tr("Channel group"))) == ItemText) {
+ SetHelp(NULL, GREENLABEL, NULL, tr("Button$Setup"));
+ iOnChannelGroup = 1;
+ } else if (strstr(ItemText, tr("Use blacklists")) == ItemText && data.blacklistMode == blacklistsSelection) {
+ SetHelp(NULL, GREENLABEL, NULL, tr("Button$Setup"));
+ iOnUseBlacklistsSelection = 1;
+ } else if (iOnExtCatItem) {
+ if (!InEditMode(ItemText, IndentMenuItem(catname), data.catvalues[iCatIndex]))
+ SetHelp(NULL, GREENLABEL, NULL, iOnExtCatItemBrowsable ? tr("Button$Select") : NULL);
+ } else if (strstr(ItemText, tr("Search term")) != ItemText)
+ SetHelp(NULL, GREENLABEL, NULL, NULL);
}
if (state == osUnknown) {
- if (HasSubMenu())
- return osContinue;
- switch (Key) {
- case kOk:
- if (data.useChannel==1)
- {
- LOCK_CHANNELS_READ;
- const cChannel *ch = Channels->GetByNumber(channelMin);
- if (ch)
- data.channelMin = ch;
- else
- {
- ERROR(tr("*** Invalid Channel ***"));
- break;
- }
- ch = Channels->GetByNumber(channelMax);
- if (ch)
- data.channelMax = ch;
- else
- {
- ERROR(tr("*** Invalid Channel ***"));
- break;
- }
- if (channelMin > channelMax)
- {
- ERROR(tr("Please check channel criteria!"));
- return osContinue;
- }
- }
- if (data.useChannel==2)
- data.channelGroup = strdup(menuitemsChGr[channelGroupNr]);
+ if (HasSubMenu())
+ return osContinue;
+ switch (Key) {
+ case kOk:
+ if (data.useChannel == 1) {
+ LOCK_CHANNELS_READ;
+ const cChannel *ch = Channels->GetByNumber(channelMin);
+ if (ch)
+ data.channelMin = ch;
+ else {
+ ERROR(tr("*** Invalid Channel ***"));
+ break;
+ }
+ ch = Channels->GetByNumber(channelMax);
+ if (ch)
+ data.channelMax = ch;
+ else {
+ ERROR(tr("*** Invalid Channel ***"));
+ break;
+ }
+ if (channelMin > channelMax) {
+ ERROR(tr("Please check channel criteria!"));
+ return osContinue;
+ }
+ }
+ if (data.useChannel == 2)
+ data.channelGroup = strdup(menuitemsChGr[channelGroupNr]);
- if ((data.useTitle || data.useSubtitle || data.useDescription) &&
- (int(strlen(data.search)) < 3) &&
- !Interface->Confirm(tr("Edit$Search text too short - use anyway?")))
- break;
+ if ((data.useTitle || data.useSubtitle || data.useDescription) &&
+ (int(strlen(data.search)) < 3) &&
+ !Interface->Confirm(tr("Edit$Search text too short - use anyway?")))
+ break;
- if (searchExt)
- {
- *searchExt = data;
- if (data.DayOfWeek == 7)
- searchExt->DayOfWeek = UserDefDayOfWeek;
+ if (searchExt) {
+ *searchExt = data;
+ if (data.DayOfWeek == 7)
+ searchExt->DayOfWeek = UserDefDayOfWeek;
- if (data.blacklistMode == blacklistsSelection)
- {
- searchExt->blacklists.Clear();
- cBlacklistObject* blacklistObj = blacklists.First();
- while(blacklistObj)
- {
- searchExt->blacklists.Add(new cBlacklistObject(blacklistObj->blacklist));
- blacklistObj = blacklists.Next(blacklistObj);
- }
- }
- else
- searchExt->blacklists.Clear();
+ if (data.blacklistMode == blacklistsSelection) {
+ searchExt->blacklists.Clear();
+ cBlacklistObject* blacklistObj = blacklists.First();
+ while (blacklistObj) {
+ searchExt->blacklists.Add(new cBlacklistObject(blacklistObj->blacklist));
+ blacklistObj = blacklists.Next(blacklistObj);
+ }
+ } else
+ searchExt->blacklists.Clear();
- state = AddSubMenu(new cMenuSearchResultsForSearch(searchExt, cTemplFile::GetTemplateByName("MenuSearchResults")));
- }
- break;
- case kRed:
- if (iOnUserDefDayItem)
- state = AddSubMenu(new cMenuEditDaysOfWeek(&UserDefDayOfWeek));
- break;
+ state = AddSubMenu(new cMenuSearchResultsForSearch(searchExt, cTemplFile::GetTemplateByName("MenuSearchResults")));
+ }
+ break;
+ case kRed:
+ if (iOnUserDefDayItem)
+ state = AddSubMenu(new cMenuEditDaysOfWeek(&UserDefDayOfWeek));
+ break;
- case kBlue:
- if (iOnUseChannelGroups || iOnChannelGroup)
- {
- if (channelGroupName)
- free(channelGroupName);
- channelGroupName = strdup(menuitemsChGr[channelGroupNr]);
- state = AddSubMenu(new cMenuChannelGroups(&channelGroupName));
- }
- if (iOnUseBlacklistsSelection)
- state = AddSubMenu(new cMenuBlacklistsSelection(&blacklists));
- if (iOnExtCatItemBrowsable)
- state = AddSubMenu(new cMenuCatValuesSelect(data.catvalues[iCatIndex], iCatIndex, SearchExtCats.Get(iCatIndex)->searchmode));
- break;
- case kGreen:
- editmode = (editmode==QUICKSEARCHSIMPLE?QUICKSEARCHEXT:QUICKSEARCHSIMPLE);
- SetHelp(NULL, GREENLABEL, NULL, NULL);
- Set();
- Display();
- break;
- case kYellow: state = osContinue;
- default: break;
- }
+ case kBlue:
+ if (iOnUseChannelGroups || iOnChannelGroup) {
+ if (channelGroupName)
+ free(channelGroupName);
+ channelGroupName = strdup(menuitemsChGr[channelGroupNr]);
+ state = AddSubMenu(new cMenuChannelGroups(&channelGroupName));
+ }
+ if (iOnUseBlacklistsSelection)
+ state = AddSubMenu(new cMenuBlacklistsSelection(&blacklists));
+ if (iOnExtCatItemBrowsable)
+ state = AddSubMenu(new cMenuCatValuesSelect(data.catvalues[iCatIndex], iCatIndex, SearchExtCats.Get(iCatIndex)->searchmode));
+ break;
+ case kGreen:
+ editmode = (editmode == QUICKSEARCHSIMPLE ? QUICKSEARCHEXT : QUICKSEARCHSIMPLE);
+ SetHelp(NULL, GREENLABEL, NULL, NULL);
+ Set();
+ Display();
+ break;
+ case kYellow:
+ state = osContinue;
+ default:
+ break;
+ }
}
- if ((iOnUseChannelGroups || iOnChannelGroup || iOnCompareCats) && bHadSubMenu && !HasSubMenu()) // return form submenu
- {
- Set();
- Display();
+ if ((iOnUseChannelGroups || iOnChannelGroup || iOnCompareCats) && bHadSubMenu && !HasSubMenu()) { // return form submenu
+ Set();
+ Display();
}
return state;
}
diff --git a/menu_quicksearch.h b/menu_quicksearch.h
index c7f6c16..f957039 100644
--- a/menu_quicksearch.h
+++ b/menu_quicksearch.h
@@ -28,12 +28,13 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "epgsearchtools.h"
// --- cMenuQuickSearch --------------------------------------------------------
-class cMenuQuickSearch : public cMenuEditSearchExt {
+class cMenuQuickSearch : public cMenuEditSearchExt
+{
int editmode;
virtual void Set();
public:
cMenuQuickSearch(cSearchExt*);
virtual eOSState ProcessKey(eKeys Key);
- };
+};
#endif
diff --git a/menu_recsdone.c b/menu_recsdone.c
index 062f93d..14dbcc8 100644
--- a/menu_recsdone.c
+++ b/menu_recsdone.c
@@ -28,15 +28,15 @@ int sortModeRecDone = 0;
cMenuRecDoneItem::cMenuRecDoneItem(cRecDone* RecDone, bool ShowEpisodeOnly)
{
- recDone = RecDone;
- showEpisodeOnly = ShowEpisodeOnly;
- Set();
+ recDone = RecDone;
+ showEpisodeOnly = ShowEpisodeOnly;
+ Set();
}
void cMenuRecDoneItem::Set()
{
if (!recDone)
- return;
+ return;
char *buffer = NULL;
char buf[32];
@@ -44,8 +44,8 @@ void cMenuRecDoneItem::Set()
tm *tm = localtime_r(&recDone->startTime, &tm_r);
strftime(buf, sizeof(buf), "%d.%m.%y %H:%M", tm);
- msprintf(&buffer, "%s\t%s~%s", buf, recDone->title && !showEpisodeOnly?recDone->title:"",
- recDone->shortText?recDone->shortText:"");
+ msprintf(&buffer, "%s\t%s~%s", buf, recDone->title && !showEpisodeOnly ? recDone->title : "",
+ recDone->shortText ? recDone->shortText : "");
SetText(buffer, false);
}
@@ -53,13 +53,13 @@ int cMenuRecDoneItem::Compare(const cListObject &ListObject) const
{
cMenuRecDoneItem *p = (cMenuRecDoneItem *)&ListObject;
if (sortModeRecDone == 0) // sort by Date
- if (recDone->startTime < p->recDone->startTime) return 1; else return -1;
- else
- {
- cString s1 = cString::sprintf("%s~%s", recDone->title?recDone->title:"", recDone->shortText?recDone->shortText:"");
- cString s2 = cString::sprintf("%s~%s", p->recDone->title?p->recDone->title:"", p->recDone->shortText?p->recDone->shortText:"");
- int res = strcasecmp(s1, s2);
- return res;
+ if (recDone->startTime < p->recDone->startTime) return 1;
+ else return -1;
+ else {
+ cString s1 = cString::sprintf("%s~%s", recDone->title ? recDone->title : "", recDone->shortText ? recDone->shortText : "");
+ cString s2 = cString::sprintf("%s~%s", p->recDone->title ? p->recDone->title : "", p->recDone->shortText ? p->recDone->shortText : "");
+ int res = strcasecmp(s1, s2);
+ return res;
}
}
@@ -69,9 +69,9 @@ int cMenuRecDoneItem::Compare(const cListObject &ListObject) const
#define SHOW_RECDONE_ORPHANED 2
cMenuRecsDone::cMenuRecsDone(cSearchExt* Search)
-:cOsdMenu("", 16)
+ : cOsdMenu("", 16)
{
- SetMenuCategory(mcUnknown);
+ SetMenuCategory(mcUnknown);
search = Search;
showMode = SHOW_RECDONE_ALL;
showEpisodeOnly = false;
@@ -83,12 +83,12 @@ cMenuRecsDone::cMenuRecsDone(cSearchExt* Search)
const char* cMenuRecsDone::ButtonBlue(cSearchExt* Search)
{
- if (showMode==SHOW_RECDONE_SEARCH && Search)
- return tr("Button$Show all");
- else if (showMode==SHOW_RECDONE_ALL)
- return tr("Button$Orphaned");
- else
- return Search->search;
+ if (showMode == SHOW_RECDONE_SEARCH && Search)
+ return tr("Button$Show all");
+ else if (showMode == SHOW_RECDONE_ALL)
+ return tr("Button$Orphaned");
+ else
+ return Search->search;
}
void cMenuRecsDone::Set()
@@ -97,14 +97,14 @@ void cMenuRecsDone::Set()
cMutexLock RecsDoneLock(&RecsDone);
cRecDone* recDone = RecsDone.First();
while (recDone) {
- if (showMode == SHOW_RECDONE_ALL ||
- (showMode == SHOW_RECDONE_SEARCH && search && recDone->searchID == search->ID) ||
- (showMode == SHOW_RECDONE_ORPHANED && recDone->searchID == -1))
- Add(new cMenuRecDoneItem(recDone, showEpisodeOnly));
- recDone = RecsDone.Next(recDone);
+ if (showMode == SHOW_RECDONE_ALL ||
+ (showMode == SHOW_RECDONE_SEARCH && search && recDone->searchID == search->ID) ||
+ (showMode == SHOW_RECDONE_ORPHANED && recDone->searchID == -1))
+ Add(new cMenuRecDoneItem(recDone, showEpisodeOnly));
+ recDone = RecsDone.Next(recDone);
}
UpdateTitle();
- SetHelp(sortModeRecDone==0?tr("Button$by name"):tr("Button$by date"), tr("Button$Delete all"), trVDR("Button$Delete"), ButtonBlue(search));
+ SetHelp(sortModeRecDone == 0 ? tr("Button$by name") : tr("Button$by date"), tr("Button$Delete all"), trVDR("Button$Delete"), ButtonBlue(search));
Sort();
}
@@ -116,24 +116,24 @@ cRecDone *cMenuRecsDone::CurrentRecDone(void)
void cMenuRecsDone::UpdateTitle()
{
- cString buffer = cString::sprintf("%d %s%s%s", Count(), tr("Recordings"), showMode == SHOW_RECDONE_ALL?"":" ", showMode != SHOW_RECDONE_SEARCH ? "":search->search);
- SetTitle(buffer);
- Display();
+ cString buffer = cString::sprintf("%d %s%s%s", Count(), tr("Recordings"), showMode == SHOW_RECDONE_ALL ? "" : " ", showMode != SHOW_RECDONE_SEARCH ? "" : search->search);
+ SetTitle(buffer);
+ Display();
}
eOSState cMenuRecsDone::Delete(void)
{
cRecDone *curRecDone = CurrentRecDone();
if (curRecDone) {
- if (Interface->Confirm(tr("Edit$Delete entry?"))) {
- LogFile.Log(1,"deleted recording done: '%s~%s'", curRecDone->title?curRecDone->title:"unknown title", curRecDone->shortText?curRecDone->shortText:"unknown subtitle");
- cMutexLock RecsDoneLock(&RecsDone);
- RecsDone.Del(curRecDone);
- RecsDone.Save();
- cOsdMenu::Del(Current());
- Display();
- UpdateTitle();
- }
+ if (Interface->Confirm(tr("Edit$Delete entry?"))) {
+ LogFile.Log(1, "deleted recording done: '%s~%s'", curRecDone->title ? curRecDone->title : "unknown title", curRecDone->shortText ? curRecDone->shortText : "unknown subtitle");
+ cMutexLock RecsDoneLock(&RecsDone);
+ RecsDone.Del(curRecDone);
+ RecsDone.Save();
+ cOsdMenu::Del(Current());
+ Display();
+ UpdateTitle();
+ }
}
return osContinue;
}
@@ -141,18 +141,17 @@ eOSState cMenuRecsDone::Delete(void)
eOSState cMenuRecsDone::DeleteAll(void)
{
if (Interface->Confirm(tr("Edit$Delete all entries?"))) {
- cMutexLock RecsDoneLock(&RecsDone);
- while(Count()>0)
- {
- cMenuRecDoneItem *item = (cMenuRecDoneItem *)Get(0);
- if (!item) break;
- cRecDone *curRecDone = item->recDone;
- RecsDone.Del(curRecDone);
- cOsdMenu::Del(0);
- }
- RecsDone.Save();
- Display();
- UpdateTitle();
+ cMutexLock RecsDoneLock(&RecsDone);
+ while (Count() > 0) {
+ cMenuRecDoneItem *item = (cMenuRecDoneItem *)Get(0);
+ if (!item) break;
+ cRecDone *curRecDone = item->recDone;
+ RecsDone.Del(curRecDone);
+ cOsdMenu::Del(0);
+ }
+ RecsDone.Save();
+ Display();
+ UpdateTitle();
}
return osContinue;
@@ -161,70 +160,73 @@ eOSState cMenuRecsDone::DeleteAll(void)
eOSState cMenuRecsDone::Summary(void)
{
if (HasSubMenu() || Count() == 0)
- return osContinue;
+ return osContinue;
cRecDone* recDone = CurrentRecDone();
if (recDone && !isempty(recDone->description))
- return AddSubMenu(new cMenuTextDone(tr("Summary"), recDone));
+ return AddSubMenu(new cMenuTextDone(tr("Summary"), recDone));
return osContinue;
}
eOSState cMenuRecsDone::ProcessKey(eKeys Key)
{
- eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown) {
- switch (Key) {
- case kOk:
- state = Summary();
- break;
- case kGreen:
- state = DeleteAll();
- break;
- case kYellow:
- state = Delete();
- break;
- case kBlue:
- showMode = (showMode+1)%3;
- Set();
- Display();
- break;
- case k0:
- showEpisodeOnly = !showEpisodeOnly;
- Set();
- Display();
- break;
- case kRed:
- sortModeRecDone = 1-sortModeRecDone;
- Set();
- Display();
- break;
- case k8:
- return osContinue;
- default: break;
+ eOSState state = cOsdMenu::ProcessKey(Key);
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk:
+ state = Summary();
+ break;
+ case kGreen:
+ state = DeleteAll();
+ break;
+ case kYellow:
+ state = Delete();
+ break;
+ case kBlue:
+ showMode = (showMode + 1) % 3;
+ Set();
+ Display();
+ break;
+ case k0:
+ showEpisodeOnly = !showEpisodeOnly;
+ Set();
+ Display();
+ break;
+ case kRed:
+ sortModeRecDone = 1 - sortModeRecDone;
+ Set();
+ Display();
+ break;
+ case k8:
+ return osContinue;
+ default:
+ break;
+ }
}
- }
- return state;
+ return state;
}
eOSState cMenuTextDone::ProcessKey(eKeys Key)
{
eOSState state = cMenuText::ProcessKey(Key);
if (state == osContinue) {
- switch (Key) {
- case kBlue:
- if (recDone->aux) return AddSubMenu(new cMenuText(tr("Auxiliary info"), recDone->aux));
- break;
- case kOk: return osBack;
- default: state = osContinue;
- }
+ switch (Key) {
+ case kBlue:
+ if (recDone->aux) return AddSubMenu(new cMenuText(tr("Auxiliary info"), recDone->aux));
+ break;
+ case kOk:
+ return osBack;
+ default:
+ state = osContinue;
+ }
}
return state;
}
// --- cMenuTextDone ----------------------------------------------------------
cMenuTextDone::cMenuTextDone(const char *Title, cRecDone* RecDone, eDvbFont Font)
-: cMenuText(Title, RecDone->description, Font), recDone(RecDone)
+ : cMenuText(Title, RecDone->description, Font), recDone(RecDone)
{
- if (recDone->aux) SetHelp(NULL, NULL, NULL, tr("Button$Aux info"));
+ if (recDone->aux) SetHelp(NULL, NULL, NULL, tr("Button$Aux info"));
}
diff --git a/menu_recsdone.h b/menu_recsdone.h
index a55ad6e..19acc94 100644
--- a/menu_recsdone.h
+++ b/menu_recsdone.h
@@ -30,8 +30,9 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include <vdr/menuitems.h>
// --- cMenuRecDoneItem ----------------------------------------------------------
-class cMenuRecDoneItem : public cOsdItem {
- public:
+class cMenuRecDoneItem : public cOsdItem
+{
+public:
cRecDone* recDone;
bool showEpisodeOnly;
cMenuRecDoneItem(cRecDone* RecDone, bool ShowEpisodeOnly = false);
@@ -40,30 +41,32 @@ class cMenuRecDoneItem : public cOsdItem {
};
// --- cMenuRecDone ----------------------------------------------------------
-class cMenuRecsDone : public cOsdMenu {
- private:
+class cMenuRecsDone : public cOsdMenu
+{
+private:
cSearchExt* search;
eOSState Delete(void);
eOSState DeleteAll(void);
const char* ButtonBlue(cSearchExt* Search);
int showMode;
bool showEpisodeOnly;
- protected:
+protected:
void Set();
virtual eOSState ProcessKey(eKeys Key);
void UpdateTitle();
eOSState Summary(void);
cRecDone* CurrentRecDone(void);
- public:
+public:
cMenuRecsDone(cSearchExt* search = NULL);
};
// --- cMenuTextDone ----------------------------------------------------------
-class cMenuTextDone : public cMenuText {
+class cMenuTextDone : public cMenuText
+{
cRecDone* recDone;
public:
cMenuTextDone(const char *Title, cRecDone* RecDone, eDvbFont Font = fontOsd);
virtual eOSState ProcessKey(eKeys Key);
- };
+};
#endif
diff --git a/menu_search.c b/menu_search.c
index 5aef353..f5bfe6f 100644
--- a/menu_search.c
+++ b/menu_search.c
@@ -37,99 +37,95 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
using namespace std;
// --- cMenuSearchExtItem ----------------------------------------------------------
-class cMenuSearchExtItem : public cOsdItem {
- private:
+class cMenuSearchExtItem : public cOsdItem
+{
+private:
public:
- cSearchExt* searchExt;
- cMenuSearchExtItem(cSearchExt* SearchExt);
- int Compare(const cListObject &ListObject) const;
- void Set(void);
- };
+ cSearchExt* searchExt;
+ cMenuSearchExtItem(cSearchExt* SearchExt);
+ int Compare(const cListObject &ListObject) const;
+ void Set(void);
+};
cMenuSearchExtItem::cMenuSearchExtItem(cSearchExt* SearchExt)
{
- searchExt = SearchExt;
- Set();
+ searchExt = SearchExt;
+ Set();
}
void cMenuSearchExtItem::Set(void)
{
- ostringstream line;
-
- if (searchExt->useAsSearchTimer)
- {
- if (searchExt->IsActiveAt(time(NULL)))
- line << ">";
- else
- line << "!";
+ ostringstream line;
+
+ if (searchExt->useAsSearchTimer) {
+ if (searchExt->IsActiveAt(time(NULL)))
+ line << ">";
+ else
+ line << "!";
}
- line << "\t";
- if (searchExt->search && strlen(searchExt->search) > 0)
- line << setiosflags(ios::left) << string(searchExt->search);
- else
- line << setiosflags(ios::left) << "*";
-
- line << "\t";
- if (searchExt->useChannel == 1)
- {
- if (searchExt->channelMin != searchExt->channelMax)
- line << setiosflags(ios::left) << searchExt->channelMin->Number() << " - " << searchExt->channelMax->Number();
- else
- line << setiosflags(ios::left) << setw(11) << (searchExt->useChannel?CHANNELNAME(searchExt->channelMin):"");
- }
- else if (searchExt->useChannel == 2)
- line << setiosflags(ios::left) << setw(11) << searchExt->channelGroup;
- else
- line << " ";
-
- line << "\t";
- if (searchExt->useTime)
- {
- ostringstream timeline;
- timeline << setfill('0') << setw(2) << searchExt->startTime / 100 << ":" << setw(2) << searchExt->startTime % 100;
- timeline << "\t";
- timeline << setfill('0') << setw(2) << searchExt->stopTime / 100 << ":" << setw(2) << searchExt->stopTime % 100;
- line << timeline.str();
- }
- else
- line << "--:--\t--:--";
-
- SetText(strdup(line.str().c_str()), false);
+ line << "\t";
+ if (searchExt->search && strlen(searchExt->search) > 0)
+ line << setiosflags(ios::left) << string(searchExt->search);
+ else
+ line << setiosflags(ios::left) << "*";
+
+ line << "\t";
+ if (searchExt->useChannel == 1) {
+ if (searchExt->channelMin != searchExt->channelMax)
+ line << setiosflags(ios::left) << searchExt->channelMin->Number() << " - " << searchExt->channelMax->Number();
+ else
+ line << setiosflags(ios::left) << setw(11) << (searchExt->useChannel ? CHANNELNAME(searchExt->channelMin) : "");
+ } else if (searchExt->useChannel == 2)
+ line << setiosflags(ios::left) << setw(11) << searchExt->channelGroup;
+ else
+ line << " ";
+
+ line << "\t";
+ if (searchExt->useTime) {
+ ostringstream timeline;
+ timeline << setfill('0') << setw(2) << searchExt->startTime / 100 << ":" << setw(2) << searchExt->startTime % 100;
+ timeline << "\t";
+ timeline << setfill('0') << setw(2) << searchExt->stopTime / 100 << ":" << setw(2) << searchExt->stopTime % 100;
+ line << timeline.str();
+ } else
+ line << "--:--\t--:--";
+
+ SetText(strdup(line.str().c_str()), false);
}
int cMenuSearchExtItem::Compare(const cListObject &ListObject) const
{
- cMenuSearchExtItem *p = (cMenuSearchExtItem *)&ListObject;
- return strcasecmp(searchExt->search, p->searchExt->search);
+ cMenuSearchExtItem *p = (cMenuSearchExtItem *)&ListObject;
+ return strcasecmp(searchExt->search, p->searchExt->search);
}
// --- cMenuEPGSearchExt ----------------------------------------------------------
cMenuEPGSearchExt::cMenuEPGSearchExt()
-:cOsdMenu("", 2, 20, 11, 6, 5)
+ : cOsdMenu("", 2, 20, 11, 6, 5)
{
- SetMenuCategory(mcPlugin);
- cMutexLock SearchExtsLock(&SearchExts);
- cSearchExt *SearchExt = SearchExts.First();
- while (SearchExt) {
- Add(new cMenuSearchExtItem(SearchExt));
- SearchExt = SearchExts.Next(SearchExt);
- }
-
- UpdateTitle();
- SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), tr("Button$Actions"));
- Sort();
+ SetMenuCategory(mcPlugin);
+ cMutexLock SearchExtsLock(&SearchExts);
+ cSearchExt *SearchExt = SearchExts.First();
+ while (SearchExt) {
+ Add(new cMenuSearchExtItem(SearchExt));
+ SearchExt = SearchExts.Next(SearchExt);
+ }
+
+ UpdateTitle();
+ SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), tr("Button$Actions"));
+ Sort();
}
void cMenuEPGSearchExt::UpdateTitle()
{
- int total=0, active=0;
+ int total = 0, active = 0;
cMutexLock SearchExtsLock(&SearchExts);
cSearchExt *SearchExt = SearchExts.First();
while (SearchExt) {
- if (SearchExt->useAsSearchTimer) active++;
- SearchExt = SearchExts.Next(SearchExt);
- total++;
+ if (SearchExt->useAsSearchTimer) active++;
+ SearchExt = SearchExts.Next(SearchExt);
+ total++;
}
cString buffer = cString::sprintf("%s (%d/%d %s)", tr("Search entries"), active, total, tr("active"));
@@ -141,113 +137,115 @@ cSearchExt *cMenuEPGSearchExt::CurrentSearchExt(void)
{
cMenuSearchExtItem *item = (cMenuSearchExtItem *)Get(Current());
if (item && SearchExts.Exists(item->searchExt))
- return item->searchExt;
+ return item->searchExt;
return NULL;
}
eOSState cMenuEPGSearchExt::New(void)
{
- if (HasSubMenu())
- return osContinue;
- return AddSubMenu(new cMenuEditSearchExt(new cSearchExt, true));
+ if (HasSubMenu())
+ return osContinue;
+ return AddSubMenu(new cMenuEditSearchExt(new cSearchExt, true));
}
eOSState cMenuEPGSearchExt::Delete(void)
{
cSearchExt *curSearchExt = CurrentSearchExt();
if (curSearchExt) {
- if (Interface->Confirm(tr("Edit$Delete search?"))) {
- int DelID = curSearchExt->ID;
- if (Interface->Confirm(tr("Delete all timers created from this search?")))
- curSearchExt->DeleteAllTimers();
- LogFile.Log(1,"search timer %s (%d) deleted", curSearchExt->search, curSearchExt->ID);
- cMutexLock SearchExtsLock(&SearchExts);
- SearchExts.Del(curSearchExt);
- SearchExts.Save();
- RecsDone.RemoveSearchID(DelID);
- TimersDone.RemoveEntriesOfSearch(DelID);
- cOsdMenu::Del(Current());
- Display();
- UpdateTitle();
- }
+ if (Interface->Confirm(tr("Edit$Delete search?"))) {
+ int DelID = curSearchExt->ID;
+ if (Interface->Confirm(tr("Delete all timers created from this search?")))
+ curSearchExt->DeleteAllTimers();
+ LogFile.Log(1, "search timer %s (%d) deleted", curSearchExt->search, curSearchExt->ID);
+ cMutexLock SearchExtsLock(&SearchExts);
+ SearchExts.Del(curSearchExt);
+ SearchExts.Save();
+ RecsDone.RemoveSearchID(DelID);
+ TimersDone.RemoveEntriesOfSearch(DelID);
+ cOsdMenu::Del(Current());
+ Display();
+ UpdateTitle();
+ }
}
return osContinue;
}
eOSState cMenuEPGSearchExt::Actions(eKeys Key)
{
- if (HasSubMenu() || Count() == 0)
- return osContinue;
- cSearchExt* search = CurrentSearchExt();
-
- cMenuSearchActions *menu;
- eOSState state = AddSubMenu(menu = new cMenuSearchActions(search, true));
- if (Key != kNone)
- state = menu->ProcessKey(Key);
- return state;
+ if (HasSubMenu() || Count() == 0)
+ return osContinue;
+ cSearchExt* search = CurrentSearchExt();
+
+ cMenuSearchActions *menu;
+ eOSState state = AddSubMenu(menu = new cMenuSearchActions(search, true));
+ if (Key != kNone)
+ state = menu->ProcessKey(Key);
+ return state;
}
eOSState cMenuEPGSearchExt::ProcessKey(eKeys Key)
{
- int SearchNumber = HasSubMenu() ? Count() : -1;
- eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown) {
- switch (Key) {
- case k0:
- if (HasSubMenu())
- return osContinue;
- if (CurrentSearchExt())
- state = AddSubMenu(new cMenuSearchActions(CurrentSearchExt()));
- else
- state = osContinue;
- break;
- case k1...k9:
- return Actions(Key);
- case kOk:
- state = Actions(k1);
- case kBlue:
- if (HasSubMenu())
- return osContinue;
- state = AddSubMenu(new cMenuSearchActions(CurrentSearchExt()));
- break;
- case kRed:
- if (HasSubMenu())
- return osContinue;
- if (CurrentSearchExt())
- state = AddSubMenu(new cMenuEditSearchExt(CurrentSearchExt()));
- else
- state = osContinue;
- break;
- case kGreen: state = New(); break;
- case kYellow: state = Delete(); break;
- default: break;
+ int SearchNumber = HasSubMenu() ? Count() : -1;
+ eOSState state = cOsdMenu::ProcessKey(Key);
+ if (state == osUnknown) {
+ switch (Key) {
+ case k0:
+ if (HasSubMenu())
+ return osContinue;
+ if (CurrentSearchExt())
+ state = AddSubMenu(new cMenuSearchActions(CurrentSearchExt()));
+ else
+ state = osContinue;
+ break;
+ case k1...k9:
+ return Actions(Key);
+ case kOk:
+ state = Actions(k1);
+ case kBlue:
+ if (HasSubMenu())
+ return osContinue;
+ state = AddSubMenu(new cMenuSearchActions(CurrentSearchExt()));
+ break;
+ case kRed:
+ if (HasSubMenu())
+ return osContinue;
+ if (CurrentSearchExt())
+ state = AddSubMenu(new cMenuEditSearchExt(CurrentSearchExt()));
+ else
+ state = osContinue;
+ break;
+ case kGreen:
+ state = New();
+ break;
+ case kYellow:
+ state = Delete();
+ break;
+ default:
+ break;
+ }
}
- }
- if (SearchNumber >= 0 && !HasSubMenu())
- {
- cMutexLock SearchExtsLock(&SearchExts);
- cSearchExt* search = SearchExts.Get(SearchNumber);
- if (search) // a newly created search was confirmed with Ok
- Add(new cMenuSearchExtItem(search));
- else
- search = CurrentSearchExt();
- // always update all entries, since channel group names may have changed and affect other searches
- Sort();
- for(int i=0; i<Count(); i++)
- {
- cMenuSearchExtItem *item = (cMenuSearchExtItem *)Get(i);
- if (item)
- {
- item->Set();
- if (item->searchExt == search)
- SetCurrent(item);
- }
- }
- Display();
- UpdateTitle();
- }
-
- return state;
+ if (SearchNumber >= 0 && !HasSubMenu()) {
+ cMutexLock SearchExtsLock(&SearchExts);
+ cSearchExt* search = SearchExts.Get(SearchNumber);
+ if (search) // a newly created search was confirmed with Ok
+ Add(new cMenuSearchExtItem(search));
+ else
+ search = CurrentSearchExt();
+ // always update all entries, since channel group names may have changed and affect other searches
+ Sort();
+ for (int i = 0; i < Count(); i++) {
+ cMenuSearchExtItem *item = (cMenuSearchExtItem *)Get(i);
+ if (item) {
+ item->Set();
+ if (item->searchExt == search)
+ SetCurrent(item);
+ }
+ }
+ Display();
+ UpdateTitle();
+ }
+
+ return state;
}
diff --git a/menu_search.h b/menu_search.h
index 8b9dbfc..0551f52 100644
--- a/menu_search.h
+++ b/menu_search.h
@@ -27,17 +27,18 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include <vdr/plugin.h>
#include "epgsearchext.h"
-class cMenuEPGSearchExt : public cOsdMenu {
- private:
- eOSState New(void);
- eOSState Delete(void);
- eOSState Actions(eKeys Key);
- protected:
- virtual eOSState ProcessKey(eKeys Key);
- public:
- cMenuEPGSearchExt();
- cSearchExt* CurrentSearchExt(void);
- void UpdateTitle();
+class cMenuEPGSearchExt : public cOsdMenu
+{
+private:
+ eOSState New(void);
+ eOSState Delete(void);
+ eOSState Actions(eKeys Key);
+protected:
+ virtual eOSState ProcessKey(eKeys Key);
+public:
+ cMenuEPGSearchExt();
+ cSearchExt* CurrentSearchExt(void);
+ void UpdateTitle();
};
#endif
diff --git a/menu_searchactions.c b/menu_searchactions.c
index ef700cc..6977143 100644
--- a/menu_searchactions.c
+++ b/menu_searchactions.c
@@ -46,9 +46,9 @@ extern int updateForced;
// --- cMenuSearchActions ---------------------------------------------------------
cMenuSearchActions::cMenuSearchActions(cSearchExt* Search, bool DirectCall)
-:cOsdMenu(tr("Search actions"))
+ : cOsdMenu(tr("Search actions"))
{
- SetMenuCategory(mcCommand);
+ SetMenuCategory(mcCommand);
directCall = DirectCall;
SetHasHotkeys();
@@ -77,126 +77,118 @@ eOSState cMenuSearchActions::Search(void)
cMenuTemplate* MenuTemplate = NULL;
if (!search) return osContinue;
if (search->menuTemplate > 0)
- MenuTemplate = cTemplFile::GetSearchTemplateByPos(search->menuTemplate);
+ MenuTemplate = cTemplFile::GetSearchTemplateByPos(search->menuTemplate);
if (!MenuTemplate)
- MenuTemplate = cTemplFile::GetTemplateByName("MenuSearchResults");
+ MenuTemplate = cTemplFile::GetTemplateByName("MenuSearchResults");
return AddSubMenu(new cMenuSearchResultsForSearch(search, MenuTemplate));
}
eOSState cMenuSearchActions::OnOffSearchtimer(void)
{
- if (search)
- {
- search->useAsSearchTimer = search->useAsSearchTimer?0:1;
- SearchExts.Save();
- if (!search->useAsSearchTimer && Interface->Confirm(tr("Disable associated timers too?")))
- search->OnOffTimers(false);
- if (search->useAsSearchTimer && Interface->Confirm(tr("Activate associated timers too?")))
- {
- search->OnOffTimers(true);
- if (!EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
- {
- cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
- INFO(tr("Search timers activated in setup."));
- }
- }
- }
- return osBack;
+ if (search) {
+ search->useAsSearchTimer = search->useAsSearchTimer ? 0 : 1;
+ SearchExts.Save();
+ if (!search->useAsSearchTimer && Interface->Confirm(tr("Disable associated timers too?")))
+ search->OnOffTimers(false);
+ if (search->useAsSearchTimer && Interface->Confirm(tr("Activate associated timers too?"))) {
+ search->OnOffTimers(true);
+ if (!EPGSearchConfig.useSearchTimers) { // enable search timer thread if necessary
+ cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
+ INFO(tr("Search timers activated in setup."));
+ }
+ }
+ }
+ return osBack;
}
eOSState cMenuSearchActions::Execute()
{
- int current = Current();
-
- if (current <= ACTION_COUNTER-1)
- {
- if (current == 0)
- return Search();
- if (current == 1)
- return OnOffSearchtimer();
- if (current == 2)
- {
- if (!EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
- {
- cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
- INFO(tr("Search timers activated in setup."));
- }
- if (Interface->Confirm(tr("Run search timer update?")))
- updateForced = 3; // with message about completion
- return osBack;
- }
- if (current == 3 && search)
- return AddSubMenu(new cMenuRecsDone(search));
- if (current == 4 && search)
- return AddSubMenu(new cMenuTimersDone(search));
- if (current == 5 && search)
- {
- if (!Interface->Confirm(tr("Copy this entry?")))
+ int current = Current();
+
+ if (current <= ACTION_COUNTER - 1) {
+ if (current == 0)
+ return Search();
+ if (current == 1)
+ return OnOffSearchtimer();
+ if (current == 2) {
+ if (!EPGSearchConfig.useSearchTimers) { // enable search timer thread if necessary
+ cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
+ INFO(tr("Search timers activated in setup."));
+ }
+ if (Interface->Confirm(tr("Run search timer update?")))
+ updateForced = 3; // with message about completion
return osBack;
- cSearchExt* copy = new cSearchExt;
- copy->CopyFromTemplate(search);
- string copyname = string(tr("Copy")) + ": " + search->search;
- strcpy(copy->search, copyname.c_str());
- cMutexLock SearchExtsLock(&SearchExts);
- copy->ID = SearchExts.GetNewID();
- SearchExts.Add(copy);
- SearchExts.Save();
- return AddSubMenu(new cMenuEditSearchExt(copy));
- }
- if (current == 6 && search)
- {
- if (!Interface->Confirm(tr("Copy this entry to templates?")))
+ }
+ if (current == 3 && search)
+ return AddSubMenu(new cMenuRecsDone(search));
+ if (current == 4 && search)
+ return AddSubMenu(new cMenuTimersDone(search));
+ if (current == 5 && search) {
+ if (!Interface->Confirm(tr("Copy this entry?")))
+ return osBack;
+ cSearchExt* copy = new cSearchExt;
+ copy->CopyFromTemplate(search);
+ string copyname = string(tr("Copy")) + ": " + search->search;
+ strcpy(copy->search, copyname.c_str());
+ cMutexLock SearchExtsLock(&SearchExts);
+ copy->ID = SearchExts.GetNewID();
+ SearchExts.Add(copy);
+ SearchExts.Save();
+ return AddSubMenu(new cMenuEditSearchExt(copy));
+ }
+ if (current == 6 && search) {
+ if (!Interface->Confirm(tr("Copy this entry to templates?")))
+ return osBack;
+ cSearchExt* templateObj = new cSearchExt;
+ templateObj->CopyFromTemplate(search);
+ strcpy(templateObj->search, search->search);
+ cMutexLock SearchTemplatesLock(&SearchTemplates);
+ templateObj->ID = SearchTemplates.GetNewID();
+ SearchTemplates.Add(templateObj);
+ SearchTemplates.Save();
return osBack;
- cSearchExt* templateObj = new cSearchExt;
- templateObj->CopyFromTemplate(search);
- strcpy(templateObj->search, search->search);
- cMutexLock SearchTemplatesLock(&SearchTemplates);
- templateObj->ID = SearchTemplates.GetNewID();
- SearchTemplates.Add(templateObj);
- SearchTemplates.Save();
- return osBack;
- }
- if (current == 7)
- return AddSubMenu(new cMenuSwitchTimers());
- if (current == 8)
- return AddSubMenu(new cMenuBlacklists());
- if (current == 9)
- {
- if (!Interface->Confirm(tr("Delete all timers created from this search?")))
+ }
+ if (current == 7)
+ return AddSubMenu(new cMenuSwitchTimers());
+ if (current == 8)
+ return AddSubMenu(new cMenuBlacklists());
+ if (current == 9) {
+ if (!Interface->Confirm(tr("Delete all timers created from this search?")))
+ return osBack;
+ search->DeleteAllTimers();
return osBack;
- search->DeleteAllTimers();
- return osBack;
- }
- if (current == 10)
- return AddSubMenu(new cMenuConflictCheck());
- }
- return osContinue;
+ }
+ if (current == 10)
+ return AddSubMenu(new cMenuConflictCheck());
+ }
+ return osContinue;
}
eOSState cMenuSearchActions::ProcessKey(eKeys Key)
{
- bool hadSubmenu = HasSubMenu();
- if (directCall && Key == k1 && !HasSubMenu())
- return Search();
+ bool hadSubmenu = HasSubMenu();
+ if (directCall && Key == k1 && !HasSubMenu())
+ return Search();
- eOSState state = cOsdMenu::ProcessKey(Key);
+ eOSState state = cOsdMenu::ProcessKey(Key);
- // jump back to calling menu, if a command was called directly with key '1' .. '9'
- if (directCall && hadSubmenu && !HasSubMenu())
- return osBack;
+ // jump back to calling menu, if a command was called directly with key '1' .. '9'
+ if (directCall && hadSubmenu && !HasSubMenu())
+ return osBack;
- if (state == osUnknown) {
- switch (Key) {
- case kGreen:
- case kYellow:
- case kBlue:
+ if (state == osUnknown) {
+ switch (Key) {
+ case kGreen:
+ case kYellow:
+ case kBlue:
return osContinue;
- case kOk:
+ case kOk:
if (!HasSubMenu())
- return Execute();
- default: break;
- }
- }
- return state;
+ return Execute();
+ default:
+ break;
+ }
+ }
+ return state;
}
diff --git a/menu_searchactions.h b/menu_searchactions.h
index 404228a..2a3a828 100644
--- a/menu_searchactions.h
+++ b/menu_searchactions.h
@@ -29,17 +29,18 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
// --- cMenuSearchActions ---------------------------------------------------------
-class cMenuSearchActions : public cOsdMenu {
+class cMenuSearchActions : public cOsdMenu
+{
private:
- cSearchExt* search;
- bool directCall;
- eOSState Search(void);
- eOSState OnOffSearchtimer(void);
- eOSState Execute();
+ cSearchExt* search;
+ bool directCall;
+ eOSState Search(void);
+ eOSState OnOffSearchtimer(void);
+ eOSState Execute();
public:
- cMenuSearchActions(cSearchExt* Search, bool DirectCall = false);
- virtual ~cMenuSearchActions();
- virtual eOSState ProcessKey(eKeys Key);
+ cMenuSearchActions(cSearchExt* Search, bool DirectCall = false);
+ virtual ~cMenuSearchActions();
+ virtual eOSState ProcessKey(eKeys Key);
};
#endif
diff --git a/menu_searchedit.c b/menu_searchedit.c
index 89c508d..7f4d6bf 100644
--- a/menu_searchedit.c
+++ b/menu_searchedit.c
@@ -47,166 +47,152 @@ cSearchExtCats SearchExtCats;
// --- cMenuEditSearchExt --------------------------------------------------------
cMenuEditSearchExt::cMenuEditSearchExt(cSearchExt *SearchExt, bool New, bool Template, bool FromEPG)
-:cOsdMenu(tr("Edit search"),32)
+ : cOsdMenu(tr("Edit search"), 32)
{
- SetMenuCategory(mcPlugin);
- templateMode = Template;
-
- SearchModes[0] = strdup(tr("phrase"));
- SearchModes[1] = strdup(tr("all words"));
- SearchModes[2] = strdup(tr("at least one word"));
- SearchModes[3] = strdup(tr("match exactly"));
- SearchModes[4] = strdup(tr("regular expression"));
- SearchModes[5] = strdup(tr("fuzzy"));
-
- DaysOfWeek[0] = strdup(WeekDayName(0));
- DaysOfWeek[1] = strdup(WeekDayName(1));
- DaysOfWeek[2] = strdup(WeekDayName(2));
- DaysOfWeek[3] = strdup(WeekDayName(3));
- DaysOfWeek[4] = strdup(WeekDayName(4));
- DaysOfWeek[5] = strdup(WeekDayName(5));
- DaysOfWeek[6] = strdup(WeekDayName(6));
- DaysOfWeek[7] = strdup(tr("user-defined"));
-
- UseChannelSel[0] = strdup(trVDR("no"));
- UseChannelSel[1] = strdup(tr("interval"));
- UseChannelSel[2] = strdup(tr("channel group"));
- UseChannelSel[3] = strdup(tr("only FTA"));
-
- SearchTimerModes[0] = strdup(tr("Record"));
- SearchTimerModes[1] = strdup(tr("Announce by OSD"));
- SearchTimerModes[2] = strdup(tr("Switch only"));
- SearchTimerModes[3] = strdup(tr("Announce and switch"));
- SearchTimerModes[4] = strdup(tr("Announce by mail"));
- SearchTimerModes[5] = strdup(tr("Inactive record"));
-
- BlacklistModes[0] = strdup(tr("only globals"));
- BlacklistModes[1] = strdup(tr("Selection"));
- BlacklistModes[2] = strdup(tr("all"));
- BlacklistModes[3] = strdup(trVDR("none"));
-
- DelModes[0] = strdup(trVDR("no"));
- DelModes[1] = strdup(tr("count recordings"));
- DelModes[2] = strdup(tr("count days"));
-
- SearchActiveModes[0] = strdup(trVDR("no"));
- SearchActiveModes[1] = strdup(trVDR("yes"));
- SearchActiveModes[2] = strdup(tr("user-defined"));
-
- CompareSubtitleModes[0] = strdup(trVDR("no"));
- CompareSubtitleModes[1] = strdup(tr("if present"));
-
- CompareDateModes[0] = strdup(trVDR("no"));
- CompareDateModes[1] = strdup(tr("same day"));
- CompareDateModes[2] = strdup(tr("same week"));
- CompareDateModes[3] = strdup(tr("same month"));
-
- // collect content string IDs
- std::set<std::string> contentStrings;
- for(unsigned int i=0; i<CONTENT_DESCRIPTOR_MAX;i++)
- {
- const string contentDescr = cEvent::ContentToString(i);
- if (!contentDescr.empty() && contentStrings.find(contentDescr) == contentStrings.end())
- {
- contentStrings.insert(contentDescr);
- contentStringIDs.push_back(i);
- }
- }
- useContentDescriptors = false;
-
- if (!templateMode && New)
- {
- cSearchExt* SearchTempl = NULL; // copy the default settings, if we have a default template
- cMutexLock SearchTemplatesLock(&SearchTemplates);
- cSearchExt *SearchExtTempl = SearchTemplates.First();
- while (SearchExtTempl)
- {
- if (SearchExtTempl->ID == EPGSearchConfig.DefSearchTemplateID)
- SearchTempl = SearchExtTempl;
- SearchExtTempl = SearchTemplates.Next(SearchExtTempl);
- }
- if (SearchTempl)
- SearchExt->CopyFromTemplate(SearchTempl, FromEPG);
- }
-
- searchExt = SearchExt;
- addIfConfirmed = New;
- if (!templateMode)
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Templates"));
-
- if (searchExt)
- {
- data = *searchExt;
- UserDefDayOfWeek = 0;
- if (searchExt->DayOfWeek < 0)
- {
- UserDefDayOfWeek = searchExt->DayOfWeek;
- data.DayOfWeek = 7;
- }
-
- menuitemsChGr = NULL;
- channelGroupName = NULL;
-
- channelMin = channelMax = cDevice::CurrentChannel();
- channelGroupNr = 0;
- if (data.channelMin)
- channelMin = data.channelMin->Number();
- if (data.channelMax)
- channelMax = data.channelMax->Number();
-
- if (data.useChannel==2)
- {
- channelGroupNr = ChannelGroups.GetIndex(data.channelGroup);
- if (channelGroupNr == -1)
- {
- free(data.channelGroup);
- data.channelGroup = NULL;
- channelGroupNr = 0; // no selection
- }
- else
- {
- channelGroupName = strdup(data.channelGroup);
- channelGroupNr++;
- }
- }
-
- contentStringsFlags = NULL;
- // set the flags for the content descriptors
- contentStringsFlags = (int*) malloc((CONTENT_DESCRIPTOR_MAX+1) * sizeof(int));
- for(unsigned int i=0; i<=CONTENT_DESCRIPTOR_MAX;i++)
- contentStringsFlags[i] = data.HasContent(i);
- useContentDescriptors = (data.contentsFilter.size() > 0);
-
- catarrayAvoidRepeats = NULL;
- catvaluesNumeric = NULL;
- if (SearchExtCats.Count() > 0)
- {
- // fill an array, that stores yes/no for using categories in avoid repeats
- catarrayAvoidRepeats = (int*) malloc(SearchExtCats.Count() * sizeof(int));
- catvaluesNumeric = (int*) malloc(SearchExtCats.Count() * sizeof(int));
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- catarrayAvoidRepeats[index] = (SearchExt->catvaluesAvoidRepeat & (1<<index))?1:0;
- catvaluesNumeric[index] = atol(SearchExt->catvalues[index]);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- }
- blacklists.Clear();
- if (data.blacklistMode == blacklistsSelection)
- {
- cBlacklistObject* blacklistObj = searchExt->blacklists.First();
- while(blacklistObj)
- {
- blacklists.Add(new cBlacklistObject(blacklistObj->blacklist));
- blacklistObj = searchExt->blacklists.Next(blacklistObj);
- }
- }
-
- Set();
- }
+ SetMenuCategory(mcPlugin);
+ templateMode = Template;
+
+ SearchModes[0] = strdup(tr("phrase"));
+ SearchModes[1] = strdup(tr("all words"));
+ SearchModes[2] = strdup(tr("at least one word"));
+ SearchModes[3] = strdup(tr("match exactly"));
+ SearchModes[4] = strdup(tr("regular expression"));
+ SearchModes[5] = strdup(tr("fuzzy"));
+
+ DaysOfWeek[0] = strdup(WeekDayName(0));
+ DaysOfWeek[1] = strdup(WeekDayName(1));
+ DaysOfWeek[2] = strdup(WeekDayName(2));
+ DaysOfWeek[3] = strdup(WeekDayName(3));
+ DaysOfWeek[4] = strdup(WeekDayName(4));
+ DaysOfWeek[5] = strdup(WeekDayName(5));
+ DaysOfWeek[6] = strdup(WeekDayName(6));
+ DaysOfWeek[7] = strdup(tr("user-defined"));
+
+ UseChannelSel[0] = strdup(trVDR("no"));
+ UseChannelSel[1] = strdup(tr("interval"));
+ UseChannelSel[2] = strdup(tr("channel group"));
+ UseChannelSel[3] = strdup(tr("only FTA"));
+
+ SearchTimerModes[0] = strdup(tr("Record"));
+ SearchTimerModes[1] = strdup(tr("Announce by OSD"));
+ SearchTimerModes[2] = strdup(tr("Switch only"));
+ SearchTimerModes[3] = strdup(tr("Announce and switch"));
+ SearchTimerModes[4] = strdup(tr("Announce by mail"));
+ SearchTimerModes[5] = strdup(tr("Inactive record"));
+
+ BlacklistModes[0] = strdup(tr("only globals"));
+ BlacklistModes[1] = strdup(tr("Selection"));
+ BlacklistModes[2] = strdup(tr("all"));
+ BlacklistModes[3] = strdup(trVDR("none"));
+
+ DelModes[0] = strdup(trVDR("no"));
+ DelModes[1] = strdup(tr("count recordings"));
+ DelModes[2] = strdup(tr("count days"));
+
+ SearchActiveModes[0] = strdup(trVDR("no"));
+ SearchActiveModes[1] = strdup(trVDR("yes"));
+ SearchActiveModes[2] = strdup(tr("user-defined"));
+
+ CompareSubtitleModes[0] = strdup(trVDR("no"));
+ CompareSubtitleModes[1] = strdup(tr("if present"));
+
+ CompareDateModes[0] = strdup(trVDR("no"));
+ CompareDateModes[1] = strdup(tr("same day"));
+ CompareDateModes[2] = strdup(tr("same week"));
+ CompareDateModes[3] = strdup(tr("same month"));
+
+ // collect content string IDs
+ std::set<std::string> contentStrings;
+ for (unsigned int i = 0; i < CONTENT_DESCRIPTOR_MAX; i++) {
+ const string contentDescr = cEvent::ContentToString(i);
+ if (!contentDescr.empty() && contentStrings.find(contentDescr) == contentStrings.end()) {
+ contentStrings.insert(contentDescr);
+ contentStringIDs.push_back(i);
+ }
+ }
+ useContentDescriptors = false;
+
+ if (!templateMode && New) {
+ cSearchExt* SearchTempl = NULL; // copy the default settings, if we have a default template
+ cMutexLock SearchTemplatesLock(&SearchTemplates);
+ cSearchExt *SearchExtTempl = SearchTemplates.First();
+ while (SearchExtTempl) {
+ if (SearchExtTempl->ID == EPGSearchConfig.DefSearchTemplateID)
+ SearchTempl = SearchExtTempl;
+ SearchExtTempl = SearchTemplates.Next(SearchExtTempl);
+ }
+ if (SearchTempl)
+ SearchExt->CopyFromTemplate(SearchTempl, FromEPG);
+ }
+
+ searchExt = SearchExt;
+ addIfConfirmed = New;
+ if (!templateMode)
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Templates"));
+
+ if (searchExt) {
+ data = *searchExt;
+ UserDefDayOfWeek = 0;
+ if (searchExt->DayOfWeek < 0) {
+ UserDefDayOfWeek = searchExt->DayOfWeek;
+ data.DayOfWeek = 7;
+ }
+
+ menuitemsChGr = NULL;
+ channelGroupName = NULL;
+
+ channelMin = channelMax = cDevice::CurrentChannel();
+ channelGroupNr = 0;
+ if (data.channelMin)
+ channelMin = data.channelMin->Number();
+ if (data.channelMax)
+ channelMax = data.channelMax->Number();
+
+ if (data.useChannel == 2) {
+ channelGroupNr = ChannelGroups.GetIndex(data.channelGroup);
+ if (channelGroupNr == -1) {
+ free(data.channelGroup);
+ data.channelGroup = NULL;
+ channelGroupNr = 0; // no selection
+ } else {
+ channelGroupName = strdup(data.channelGroup);
+ channelGroupNr++;
+ }
+ }
+
+ contentStringsFlags = NULL;
+ // set the flags for the content descriptors
+ contentStringsFlags = (int*) malloc((CONTENT_DESCRIPTOR_MAX + 1) * sizeof(int));
+ for (unsigned int i = 0; i <= CONTENT_DESCRIPTOR_MAX; i++)
+ contentStringsFlags[i] = data.HasContent(i);
+ useContentDescriptors = (data.contentsFilter.size() > 0);
+
+ catarrayAvoidRepeats = NULL;
+ catvaluesNumeric = NULL;
+ if (SearchExtCats.Count() > 0) {
+ // fill an array, that stores yes/no for using categories in avoid repeats
+ catarrayAvoidRepeats = (int*) malloc(SearchExtCats.Count() * sizeof(int));
+ catvaluesNumeric = (int*) malloc(SearchExtCats.Count() * sizeof(int));
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ catarrayAvoidRepeats[index] = (SearchExt->catvaluesAvoidRepeat & (1 << index)) ? 1 : 0;
+ catvaluesNumeric[index] = atol(SearchExt->catvalues[index]);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+ }
+ blacklists.Clear();
+ if (data.blacklistMode == blacklistsSelection) {
+ cBlacklistObject* blacklistObj = searchExt->blacklists.First();
+ while (blacklistObj) {
+ blacklists.Add(new cBlacklistObject(blacklistObj->blacklist));
+ blacklistObj = searchExt->blacklists.Next(blacklistObj);
+ }
+ }
+
+ Set();
+ }
}
void cMenuEditSearchExt::AddHelp(const char* helpText)
@@ -216,253 +202,226 @@ void cMenuEditSearchExt::AddHelp(const char* helpText)
void cMenuEditSearchExt::Set()
{
- int current = Current();
- Clear();
- helpTexts.clear();
-
- if (templateMode)
- {
- Add(new cMenuEditStrItem( tr("Template name"), data.search, sizeof(data.search), tr(AllowedChars)));
- AddHelp(tr("Help$Specify the name of the template."));
- }
- else
- {
- Add(new cMenuEditStrItem( tr("Search term"), data.search, sizeof(data.search), tr(AllowedChars)));
- AddHelp(tr("Help$Specify here the term to search for."));
- }
-
- Add(new cMenuEditStraItem(tr("Search mode"), &data.mode, 6, SearchModes));
- AddHelp(tr("Help$The following search modes exist:\n\n- phrase: searches for sub terms\n- all words: all single words must appear\n- at least one word: at least one single word must appear\n- match exactly: must match exactly\n- regular expression: match a regular expression\n- fuzzy searching: searches approximately"));
-
- if (data.mode == 5) // fuzzy
- {
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Tolerance")), &data.fuzzyTolerance, 1, 9));
- AddHelp(tr("Help$This sets the tolerance of fuzzy searching. The value represents the allowed errors."));
- }
-
- Add(new cMenuEditBoolItem( tr("Match case"), &data.useCase, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'Yes' if your search should match the case."));
- Add(new cMenuEditBoolItem( tr("Use title"), &data.useTitle, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'Yes' if you like to search in the title of an event."));
- Add(new cMenuEditBoolItem( tr("Use subtitle"), &data.useSubtitle, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'Yes' if you like to search in the episode of an event."));
- Add(new cMenuEditBoolItem( tr("Use description"), &data.useDescription, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'Yes' if you like to search in the summary of an event."));
-
- Add(new cMenuEditBoolItem( tr("Use content descriptor"), &useContentDescriptors, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'Yes' if you want to search the contents by a descriptor."));
- if (useContentDescriptors)
- {
- vector<int>::const_iterator it;
- for(unsigned int i=0; i< contentStringIDs.size(); i++)
- {
- int level = (contentStringIDs[i] % 0x10==0?1:2);
- Add(new cMenuEditBoolItem(IndentMenuItem(tr(cEvent::ContentToString(contentStringIDs[i])), level), &contentStringsFlags[contentStringIDs[i]], trVDR("no"), trVDR("yes")));
- }
- }
-
- // show Categories only if we have them
- if (SearchExtCats.Count() > 0)
- {
- Add(new cMenuEditBoolItem( tr("Use extended EPG info"), &data.useExtEPGInfo, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$The summary of an event, can contain additional information like 'Genre', 'Category', 'Year',... called 'EPG categories' within EPGSearch. External EPG providers often deliver this information. This allows refining a search and other nice things, like searching for the 'tip of the day'. To use it set this to 'Yes'."));
- if (data.useExtEPGInfo)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- if (SearchExtCat->searchmode >= 10)
- Add(new cMenuEditIntItem(IndentMenuItem(SearchExtCat->menuname), &catvaluesNumeric[index], 0, 999999, ""));
- else
- Add(new cMenuEditStrItem( IndentMenuItem(SearchExtCat->menuname), data.catvalues[index], MaxFileName, tr(AllowedChars)));
- AddHelp(tr("Help$The file epgsearchcats.conf specifies the search mode for this entry. One can search by text or by value. You can also edit a list of predefined values in this file that can be selected here."));
-
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("Ignore missing categories")), &data.ignoreMissingEPGCats, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$If a selected category is not part of the summary of an event this normally excludes this event from the search results. To avoid this, set this option to 'Yes', but please handle this with care to avoid a huge amount of results.")); }
- }
-
- Add(new cMenuEditStraItem(tr("Use channel"), &data.useChannel, 4, UseChannelSel));
- if (data.useChannel==1)
- {
- Add(new cMenuEditChanItem(tr(" from channel"), &channelMin));
- Add(new cMenuEditChanItem(tr(" to channel"), &channelMax));
- }
- if (data.useChannel==2)
- {
- // create the char array for the menu display
- if (menuitemsChGr) delete [] menuitemsChGr;
- menuitemsChGr = ChannelGroups.CreateMenuitemsList();
- int oldchannelGroupNr = channelGroupNr;
- channelGroupNr = ChannelGroups.GetIndex(channelGroupName);
- if (channelGroupNr == -1)
- {
- if (oldchannelGroupNr > 0 && oldchannelGroupNr <= ChannelGroups.Count()) // perhaps its name was changed
- channelGroupNr = oldchannelGroupNr;
- else
- channelGroupNr = 0; // no selection
- }
- else
- channelGroupNr++;
- Add(new cMenuEditStraItem(IndentMenuItem(tr("Channel group")), &channelGroupNr, ChannelGroups.Count()+1, menuitemsChGr));
- }
-
- Add(new cMenuEditBoolItem( tr("Use time"), &data.useTime, trVDR("no"), trVDR("yes")));
- if (data.useTime == true)
- {
- Add(new cMenuEditTimeItem(tr(" Start after"), &data.startTime));
- Add(new cMenuEditTimeItem(tr(" Start before"), &data.stopTime));
- }
- Add(new cMenuEditBoolItem( tr("Use duration"), &data.useDuration, trVDR("no"), trVDR("yes")));
- if (data.useDuration == true)
- {
- Add(new cMenuEditTimeItem(tr(" Min. duration"), &data.minDuration));
- Add(new cMenuEditTimeItem(tr(" Max. duration"), &data.maxDuration));
- }
- Add(new cMenuEditBoolItem( tr("Use day of week"), &data.useDayOfWeek, trVDR("no"), trVDR("yes")));
- if (data.useDayOfWeek)
- {
- if (data.DayOfWeek < 0)
- {
- UserDefDayOfWeek = data.DayOfWeek;
- data.DayOfWeek = 7;
- }
- Add(new cMenuEditStraItem(IndentMenuItem(tr("Day of week")), &data.DayOfWeek, 8, DaysOfWeek));
- }
- Add(new cMenuEditStraItem(tr("Use blacklists"), &data.blacklistMode, 4, BlacklistModes));
-
- if (EPGSearchConfig.showFavoritesMenu)
- Add(new cMenuEditBoolItem( tr("Use in favorites menu"), &data.useInFavorites, trVDR("no"), trVDR("yes")));
-
- int countSearchTemplates = 0;
- if ((countSearchTemplates = cTemplFile::CountSearchResultsTemplates()) > 1)
- {
- Add(new cMenuEditStraItem(tr("Result menu layout"), &data.menuTemplate, countSearchTemplates, cTemplFile::SearchTemplates));
- }
-
- Add(new cMenuEditStraItem( tr("Use as search timer"), &data.useAsSearchTimer, 3, SearchActiveModes));
- if (data.useAsSearchTimer)
- {
- Add(new cMenuEditStraItem(IndentMenuItem(tr("Action")), &data.action, 6, SearchTimerModes));
- if (data.action == searchTimerActionSwitchOnly)
- {
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Switch ... minutes before start")), &data.switchMinsBefore, 0, 99));
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("Unmute sound")), &data.unmuteSoundOnSwitch, trVDR("no"), trVDR("yes")));
- }
- if (data.action == searchTimerActionAnnounceAndSwitch)
- {
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Ask ... minutes before start")), &data.switchMinsBefore, 0, 99));
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("Unmute sound")), &data.unmuteSoundOnSwitch, trVDR("no"), trVDR("yes")));
- }
- if ((data.action == searchTimerActionRecord) || (data.action == searchTimerActionInactiveRecord))
- {
- Add(new cMenuEditBoolItem( tr(" Series recording"), &data.useEpisode, trVDR("no"), trVDR("yes")));
- Add(new cMenuEditStrItem(IndentMenuItem(tr("Directory")), data.directory, sizeof(data.directory), tr(AllowedChars)));
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Delete recordings after ... days")), &data.delAfterDays, 0, 999));
- if (data.delAfterDays > 0)
- Add(new cMenuEditIntItem(IndentMenuItem(IndentMenuItem(tr("Keep ... recordings"))), &data.recordingsKeep, 0, 999));
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Pause when ... recordings exist")), &data.pauseOnNrRecordings, 0, 999));
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("Avoid repeats")), &data.avoidRepeats, trVDR("no"), trVDR("yes")));
- if (data.avoidRepeats)
- {
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Allowed repeats"),2), &data.allowedRepeats, 0, 99));
- if (data.allowedRepeats > 0)
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Only repeats within ... days"),2), &data.repeatsWithinDays, 0, 999));
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("Compare title"),2), &data.compareTitle, trVDR("no"), trVDR("yes")));
- Add(new cMenuEditStraItem(IndentMenuItem(tr("Compare subtitle"),2), &data.compareSubtitle, 2, CompareSubtitleModes));
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("Compare summary"),2), &data.compareSummary, trVDR("no"), trVDR("yes")));
- if (data.compareSummary)
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Min. match in %"),3), &data.compareSummaryMatchInPercent, 1, 100));
- Add(new cMenuEditStraItem(IndentMenuItem(tr("Compare date"),2), &data.compareDate, 4, CompareDateModes));
- // show 'Compare categories' only if we have them
- if (SearchExtCats.Count() > 0)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int iUsed = 0;
- int index = 0;
- while (SearchExtCat)
- {
- if (catarrayAvoidRepeats[index])
- iUsed++;
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
-
- cString itemtext = cString::sprintf("%s (%d/%d)", tr("Compare categories"), iUsed, SearchExtCats.Count());
- Add(new cOsdItem(IndentMenuItem(IndentMenuItem(itemtext))));
- }
- }
-
- Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Priority")), &data.Priority, 0, MAXPRIORITY));
- Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Lifetime")), &data.Lifetime, 0, MAXLIFETIME));
- Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Margin at start (min)")), &data.MarginStart, -INT_MAX, INT_MAX));
- Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Margin at stop (min)")), &data.MarginStop, -INT_MAX, INT_MAX));
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("VPS")), &data.useVPS, trVDR("no"), trVDR("yes")));
- }
- if ((data.action == searchTimerActionRecord) || (data.action == searchTimerActionInactiveRecord))
- {
- Add(new cMenuEditStraItem(IndentMenuItem(tr("Auto delete")), &data.delMode, 3, DelModes));
- if (data.delMode == 1)
- Add(new cMenuEditIntItem(IndentMenuItem(IndentMenuItem(tr("after ... recordings"))), &data.delAfterCountRecs, 0, 999));
- else if (data.delMode == 2)
- Add(new cMenuEditIntItem(IndentMenuItem(IndentMenuItem(tr("after ... days after first rec."))), &data.delAfterDaysOfFirstRec, 0, 999));
- }
- }
- SetCurrent(Get(current));
+ int current = Current();
+ Clear();
+ helpTexts.clear();
+
+ if (templateMode) {
+ Add(new cMenuEditStrItem(tr("Template name"), data.search, sizeof(data.search), tr(AllowedChars)));
+ AddHelp(tr("Help$Specify the name of the template."));
+ } else {
+ Add(new cMenuEditStrItem(tr("Search term"), data.search, sizeof(data.search), tr(AllowedChars)));
+ AddHelp(tr("Help$Specify here the term to search for."));
+ }
+
+ Add(new cMenuEditStraItem(tr("Search mode"), &data.mode, 6, SearchModes));
+ AddHelp(tr("Help$The following search modes exist:\n\n- phrase: searches for sub terms\n- all words: all single words must appear\n- at least one word: at least one single word must appear\n- match exactly: must match exactly\n- regular expression: match a regular expression\n- fuzzy searching: searches approximately"));
+
+ if (data.mode == 5) { // fuzzy
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Tolerance")), &data.fuzzyTolerance, 1, 9));
+ AddHelp(tr("Help$This sets the tolerance of fuzzy searching. The value represents the allowed errors."));
+ }
+
+ Add(new cMenuEditBoolItem(tr("Match case"), &data.useCase, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'Yes' if your search should match the case."));
+ Add(new cMenuEditBoolItem(tr("Use title"), &data.useTitle, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'Yes' if you like to search in the title of an event."));
+ Add(new cMenuEditBoolItem(tr("Use subtitle"), &data.useSubtitle, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'Yes' if you like to search in the episode of an event."));
+ Add(new cMenuEditBoolItem(tr("Use description"), &data.useDescription, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'Yes' if you like to search in the summary of an event."));
+
+ Add(new cMenuEditBoolItem(tr("Use content descriptor"), &useContentDescriptors, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'Yes' if you want to search the contents by a descriptor."));
+ if (useContentDescriptors) {
+ vector<int>::const_iterator it;
+ for (unsigned int i = 0; i < contentStringIDs.size(); i++) {
+ int level = (contentStringIDs[i] % 0x10 == 0 ? 1 : 2);
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr(cEvent::ContentToString(contentStringIDs[i])), level), &contentStringsFlags[contentStringIDs[i]], trVDR("no"), trVDR("yes")));
+ }
+ }
+
+ // show Categories only if we have them
+ if (SearchExtCats.Count() > 0) {
+ Add(new cMenuEditBoolItem(tr("Use extended EPG info"), &data.useExtEPGInfo, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$The summary of an event, can contain additional information like 'Genre', 'Category', 'Year',... called 'EPG categories' within EPGSearch. External EPG providers often deliver this information. This allows refining a search and other nice things, like searching for the 'tip of the day'. To use it set this to 'Yes'."));
+ if (data.useExtEPGInfo) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ if (SearchExtCat->searchmode >= 10)
+ Add(new cMenuEditIntItem(IndentMenuItem(SearchExtCat->menuname), &catvaluesNumeric[index], 0, 999999, ""));
+ else
+ Add(new cMenuEditStrItem(IndentMenuItem(SearchExtCat->menuname), data.catvalues[index], MaxFileName, tr(AllowedChars)));
+ AddHelp(tr("Help$The file epgsearchcats.conf specifies the search mode for this entry. One can search by text or by value. You can also edit a list of predefined values in this file that can be selected here."));
+
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("Ignore missing categories")), &data.ignoreMissingEPGCats, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$If a selected category is not part of the summary of an event this normally excludes this event from the search results. To avoid this, set this option to 'Yes', but please handle this with care to avoid a huge amount of results."));
+ }
+ }
+
+ Add(new cMenuEditStraItem(tr("Use channel"), &data.useChannel, 4, UseChannelSel));
+ if (data.useChannel == 1) {
+ Add(new cMenuEditChanItem(tr(" from channel"), &channelMin));
+ Add(new cMenuEditChanItem(tr(" to channel"), &channelMax));
+ }
+ if (data.useChannel == 2) {
+ // create the char array for the menu display
+ if (menuitemsChGr) delete [] menuitemsChGr;
+ menuitemsChGr = ChannelGroups.CreateMenuitemsList();
+ int oldchannelGroupNr = channelGroupNr;
+ channelGroupNr = ChannelGroups.GetIndex(channelGroupName);
+ if (channelGroupNr == -1) {
+ if (oldchannelGroupNr > 0 && oldchannelGroupNr <= ChannelGroups.Count()) // perhaps its name was changed
+ channelGroupNr = oldchannelGroupNr;
+ else
+ channelGroupNr = 0; // no selection
+ } else
+ channelGroupNr++;
+ Add(new cMenuEditStraItem(IndentMenuItem(tr("Channel group")), &channelGroupNr, ChannelGroups.Count() + 1, menuitemsChGr));
+ }
+
+ Add(new cMenuEditBoolItem(tr("Use time"), &data.useTime, trVDR("no"), trVDR("yes")));
+ if (data.useTime == true) {
+ Add(new cMenuEditTimeItem(tr(" Start after"), &data.startTime));
+ Add(new cMenuEditTimeItem(tr(" Start before"), &data.stopTime));
+ }
+ Add(new cMenuEditBoolItem(tr("Use duration"), &data.useDuration, trVDR("no"), trVDR("yes")));
+ if (data.useDuration == true) {
+ Add(new cMenuEditTimeItem(tr(" Min. duration"), &data.minDuration));
+ Add(new cMenuEditTimeItem(tr(" Max. duration"), &data.maxDuration));
+ }
+ Add(new cMenuEditBoolItem(tr("Use day of week"), &data.useDayOfWeek, trVDR("no"), trVDR("yes")));
+ if (data.useDayOfWeek) {
+ if (data.DayOfWeek < 0) {
+ UserDefDayOfWeek = data.DayOfWeek;
+ data.DayOfWeek = 7;
+ }
+ Add(new cMenuEditStraItem(IndentMenuItem(tr("Day of week")), &data.DayOfWeek, 8, DaysOfWeek));
+ }
+ Add(new cMenuEditStraItem(tr("Use blacklists"), &data.blacklistMode, 4, BlacklistModes));
+
+ if (EPGSearchConfig.showFavoritesMenu)
+ Add(new cMenuEditBoolItem(tr("Use in favorites menu"), &data.useInFavorites, trVDR("no"), trVDR("yes")));
+
+ int countSearchTemplates = 0;
+ if ((countSearchTemplates = cTemplFile::CountSearchResultsTemplates()) > 1) {
+ Add(new cMenuEditStraItem(tr("Result menu layout"), &data.menuTemplate, countSearchTemplates, cTemplFile::SearchTemplates));
+ }
+
+ Add(new cMenuEditStraItem(tr("Use as search timer"), &data.useAsSearchTimer, 3, SearchActiveModes));
+ if (data.useAsSearchTimer) {
+ Add(new cMenuEditStraItem(IndentMenuItem(tr("Action")), &data.action, 6, SearchTimerModes));
+ if (data.action == searchTimerActionSwitchOnly) {
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Switch ... minutes before start")), &data.switchMinsBefore, 0, 99));
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("Unmute sound")), &data.unmuteSoundOnSwitch, trVDR("no"), trVDR("yes")));
+ }
+ if (data.action == searchTimerActionAnnounceAndSwitch) {
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Ask ... minutes before start")), &data.switchMinsBefore, 0, 99));
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("Unmute sound")), &data.unmuteSoundOnSwitch, trVDR("no"), trVDR("yes")));
+ }
+ if ((data.action == searchTimerActionRecord) || (data.action == searchTimerActionInactiveRecord)) {
+ Add(new cMenuEditBoolItem(tr(" Series recording"), &data.useEpisode, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditStrItem(IndentMenuItem(tr("Directory")), data.directory, sizeof(data.directory), tr(AllowedChars)));
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Delete recordings after ... days")), &data.delAfterDays, 0, 999));
+ if (data.delAfterDays > 0)
+ Add(new cMenuEditIntItem(IndentMenuItem(IndentMenuItem(tr("Keep ... recordings"))), &data.recordingsKeep, 0, 999));
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Pause when ... recordings exist")), &data.pauseOnNrRecordings, 0, 999));
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("Avoid repeats")), &data.avoidRepeats, trVDR("no"), trVDR("yes")));
+ if (data.avoidRepeats) {
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Allowed repeats"), 2), &data.allowedRepeats, 0, 99));
+ if (data.allowedRepeats > 0)
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Only repeats within ... days"), 2), &data.repeatsWithinDays, 0, 999));
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("Compare title"), 2), &data.compareTitle, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditStraItem(IndentMenuItem(tr("Compare subtitle"), 2), &data.compareSubtitle, 2, CompareSubtitleModes));
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("Compare summary"), 2), &data.compareSummary, trVDR("no"), trVDR("yes")));
+ if (data.compareSummary)
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Min. match in %"), 3), &data.compareSummaryMatchInPercent, 1, 100));
+ Add(new cMenuEditStraItem(IndentMenuItem(tr("Compare date"), 2), &data.compareDate, 4, CompareDateModes));
+ // show 'Compare categories' only if we have them
+ if (SearchExtCats.Count() > 0) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int iUsed = 0;
+ int index = 0;
+ while (SearchExtCat) {
+ if (catarrayAvoidRepeats[index])
+ iUsed++;
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+
+ cString itemtext = cString::sprintf("%s (%d/%d)", tr("Compare categories"), iUsed, SearchExtCats.Count());
+ Add(new cOsdItem(IndentMenuItem(IndentMenuItem(itemtext))));
+ }
+ }
+
+ Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Priority")), &data.Priority, 0, MAXPRIORITY));
+ Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Lifetime")), &data.Lifetime, 0, MAXLIFETIME));
+ Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Margin at start (min)")), &data.MarginStart, -INT_MAX, INT_MAX));
+ Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Margin at stop (min)")), &data.MarginStop, -INT_MAX, INT_MAX));
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("VPS")), &data.useVPS, trVDR("no"), trVDR("yes")));
+ }
+ if ((data.action == searchTimerActionRecord) || (data.action == searchTimerActionInactiveRecord)) {
+ Add(new cMenuEditStraItem(IndentMenuItem(tr("Auto delete")), &data.delMode, 3, DelModes));
+ if (data.delMode == 1)
+ Add(new cMenuEditIntItem(IndentMenuItem(IndentMenuItem(tr("after ... recordings"))), &data.delAfterCountRecs, 0, 999));
+ else if (data.delMode == 2)
+ Add(new cMenuEditIntItem(IndentMenuItem(IndentMenuItem(tr("after ... days after first rec."))), &data.delAfterDaysOfFirstRec, 0, 999));
+ }
+ }
+ SetCurrent(Get(current));
}
cMenuEditSearchExt::~cMenuEditSearchExt()
{
- if (searchExt && addIfConfirmed)
- delete searchExt; // apparently it wasn't confirmed
- if (menuitemsChGr)
- free(menuitemsChGr);
- if (channelGroupName)
- free(channelGroupName);
- if (catarrayAvoidRepeats)
- free(catarrayAvoidRepeats);
- if (catvaluesNumeric)
- free(catvaluesNumeric);
- if (contentStringsFlags)
- free(contentStringsFlags);
-
- int i;
- for(i=0; i<=5; i++)
- free(SearchModes[i]);
- for(i=0; i<=7; i++)
- free(DaysOfWeek[i]);
- for(i=0; i<=3; i++)
- free(UseChannelSel[i]);
- for(i=0; i<=5; i++)
- free(SearchTimerModes[i]);
- for(i=0; i<=3; i++)
- free(BlacklistModes[i]);
- for(i=0; i<=2; i++)
- free(DelModes[i]);
- for(i=0; i<=2; i++)
- free(SearchActiveModes[i]);
- for(i=0; i<=1; i++)
- free(CompareSubtitleModes[i]);
- for(i=0; i<=3; i++)
- free(CompareDateModes[i]);
+ if (searchExt && addIfConfirmed)
+ delete searchExt; // apparently it wasn't confirmed
+ if (menuitemsChGr)
+ free(menuitemsChGr);
+ if (channelGroupName)
+ free(channelGroupName);
+ if (catarrayAvoidRepeats)
+ free(catarrayAvoidRepeats);
+ if (catvaluesNumeric)
+ free(catvaluesNumeric);
+ if (contentStringsFlags)
+ free(contentStringsFlags);
+
+ int i;
+ for (i = 0; i <= 5; i++)
+ free(SearchModes[i]);
+ for (i = 0; i <= 7; i++)
+ free(DaysOfWeek[i]);
+ for (i = 0; i <= 3; i++)
+ free(UseChannelSel[i]);
+ for (i = 0; i <= 5; i++)
+ free(SearchTimerModes[i]);
+ for (i = 0; i <= 3; i++)
+ free(BlacklistModes[i]);
+ for (i = 0; i <= 2; i++)
+ free(DelModes[i]);
+ for (i = 0; i <= 2; i++)
+ free(SearchActiveModes[i]);
+ for (i = 0; i <= 1; i++)
+ free(CompareSubtitleModes[i]);
+ for (i = 0; i <= 3; i++)
+ free(CompareDateModes[i]);
}
eOSState cMenuEditSearchExt::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;
@@ -470,743 +429,666 @@ eOSState cMenuEditSearchExt::Help()
eOSState cMenuEditSearchExt::ProcessKey(eKeys Key)
{
- bool bHadSubMenu = HasSubMenu();
-
- int iTemp_mode = data.mode;
- int iTemp_useTime = data.useTime;
- int iTemp_useChannel = data.useChannel;
- int iTemp_useDuration = data.useDuration;
- int iTemp_useDayOfWeek = data.useDayOfWeek;
- int iTemp_useAsSearchTimer = data.useAsSearchTimer;
- int iTemp_useExtEPGInfo = data.useExtEPGInfo;
- int iTemp_useContentDescriptor = useContentDescriptors;
- int iTemp_avoidRepeats = data.avoidRepeats;
- int iTemp_allowedRepeats = data.allowedRepeats;
- int iTemp_delAfterDays = data.delAfterDays;
- int iTemp_action = data.action;
- int iTemp_delMode = data.delMode;
- int iTemp_compareSummary = data.compareSummary;
-
- eOSState state = cOsdMenu::ProcessKey(Key);
-
- if (iTemp_mode != data.mode ||
- iTemp_useTime != data.useTime ||
- iTemp_useChannel != data.useChannel ||
- iTemp_useDuration != data.useDuration ||
- iTemp_useDayOfWeek != data.useDayOfWeek ||
- iTemp_useAsSearchTimer != data.useAsSearchTimer ||
- iTemp_useExtEPGInfo != data.useExtEPGInfo ||
- iTemp_useContentDescriptor != useContentDescriptors ||
- iTemp_avoidRepeats != data.avoidRepeats ||
- iTemp_allowedRepeats != data.allowedRepeats ||
- iTemp_delAfterDays != data.delAfterDays ||
- iTemp_action != data.action ||
- iTemp_delMode != data.delMode ||
- iTemp_compareSummary != data.compareSummary)
- {
- Set();
- Display();
- if ((iTemp_useAsSearchTimer != data.useAsSearchTimer || iTemp_action != data.action) && data.useAsSearchTimer) // if search timer menu is dropped then scroll down to display all contents
- {
- int cur = Current();
- PageDown();
- SetCurrent(Get(cur));
- Display();
- }
- }
- const char* ItemText = Get(Current())->Text();
-
- if (!HasSubMenu())
- {
- if (strlen(ItemText)>0 && strstr(ItemText, tr(" from channel")) == ItemText && ((Key >= k0 && Key <= k9) || Key == kLeft || Key == kRight))
- {
- channelMax = channelMin;
- Set();
- Display();
- }
- }
-
- int iOnUserDefDayItem = 0;
- int iOnDirectoryItem = 0;
- int iOnUseChannelGroups = 0;
- int iOnChannelGroup = 0;
- int iOnAvoidRepeats = 0;
- int iOnCompareCats = 0;
- int iOnTerm = 0;
- int iOnUseBlacklistsSelection = 0;
- int iOnExtCatItemBrowsable = 0;
- int iOnUseAsSearchTimer = 0;
-
- int iCatIndex = -1;
- char* catname = NULL;
-
- if (!HasSubMenu() && strlen(ItemText)>0)
- {
- // check, if on an item of ext. EPG info
- int iOnExtCatItem = 0;
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- if (strstr(ItemText, IndentMenuItem(SearchExtCat->menuname)) == ItemText)
- {
- iOnExtCatItem = 1;
- if (SearchExtCat->nvalues > 0)
- iOnExtCatItemBrowsable = 1;
- iCatIndex = index;
- catname = SearchExtCat->menuname;
- break;
- }
- index++;
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- }
-
- if (strstr(ItemText, tr("Search term")) == ItemText)
- {
- if (!InEditMode(ItemText, tr("Search term"), data.search)) // show template for a new search
- {
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Templates"));
- iOnTerm = 1;
- }
- }
- else if (strstr(ItemText, IndentMenuItem(tr("Day of week"))) == ItemText)
- {
- if (data.DayOfWeek == 7)
- {
- SetHelp(trVDR("Button$Edit"));
- iOnUserDefDayItem = 1;
- }
- else
- SetHelp(NULL, NULL, tr("Button$Help"));
- }
- else if (strstr(ItemText, tr("Use as search timer")) == ItemText)
- {
- if (data.useAsSearchTimer == 2)
- {
+ bool bHadSubMenu = HasSubMenu();
+
+ int iTemp_mode = data.mode;
+ int iTemp_useTime = data.useTime;
+ int iTemp_useChannel = data.useChannel;
+ int iTemp_useDuration = data.useDuration;
+ int iTemp_useDayOfWeek = data.useDayOfWeek;
+ int iTemp_useAsSearchTimer = data.useAsSearchTimer;
+ int iTemp_useExtEPGInfo = data.useExtEPGInfo;
+ int iTemp_useContentDescriptor = useContentDescriptors;
+ int iTemp_avoidRepeats = data.avoidRepeats;
+ int iTemp_allowedRepeats = data.allowedRepeats;
+ int iTemp_delAfterDays = data.delAfterDays;
+ int iTemp_action = data.action;
+ int iTemp_delMode = data.delMode;
+ int iTemp_compareSummary = data.compareSummary;
+
+ eOSState state = cOsdMenu::ProcessKey(Key);
+
+ if (iTemp_mode != data.mode ||
+ iTemp_useTime != data.useTime ||
+ iTemp_useChannel != data.useChannel ||
+ iTemp_useDuration != data.useDuration ||
+ iTemp_useDayOfWeek != data.useDayOfWeek ||
+ iTemp_useAsSearchTimer != data.useAsSearchTimer ||
+ iTemp_useExtEPGInfo != data.useExtEPGInfo ||
+ iTemp_useContentDescriptor != useContentDescriptors ||
+ iTemp_avoidRepeats != data.avoidRepeats ||
+ iTemp_allowedRepeats != data.allowedRepeats ||
+ iTemp_delAfterDays != data.delAfterDays ||
+ iTemp_action != data.action ||
+ iTemp_delMode != data.delMode ||
+ iTemp_compareSummary != data.compareSummary) {
+ Set();
+ Display();
+ if ((iTemp_useAsSearchTimer != data.useAsSearchTimer || iTemp_action != data.action) && data.useAsSearchTimer) { // if search timer menu is dropped then scroll down to display all contents
+ int cur = Current();
+ PageDown();
+ SetCurrent(Get(cur));
+ Display();
+ }
+ }
+ const char* ItemText = Get(Current())->Text();
+
+ if (!HasSubMenu()) {
+ if (strlen(ItemText) > 0 && strstr(ItemText, tr(" from channel")) == ItemText && ((Key >= k0 && Key <= k9) || Key == kLeft || Key == kRight)) {
+ channelMax = channelMin;
+ Set();
+ Display();
+ }
+ }
+
+ int iOnUserDefDayItem = 0;
+ int iOnDirectoryItem = 0;
+ int iOnUseChannelGroups = 0;
+ int iOnChannelGroup = 0;
+ int iOnAvoidRepeats = 0;
+ int iOnCompareCats = 0;
+ int iOnTerm = 0;
+ int iOnUseBlacklistsSelection = 0;
+ int iOnExtCatItemBrowsable = 0;
+ int iOnUseAsSearchTimer = 0;
+
+ int iCatIndex = -1;
+ char* catname = NULL;
+
+ if (!HasSubMenu() && strlen(ItemText) > 0) {
+ // check, if on an item of ext. EPG info
+ int iOnExtCatItem = 0;
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ if (strstr(ItemText, IndentMenuItem(SearchExtCat->menuname)) == ItemText) {
+ iOnExtCatItem = 1;
+ if (SearchExtCat->nvalues > 0)
+ iOnExtCatItemBrowsable = 1;
+ iCatIndex = index;
+ catname = SearchExtCat->menuname;
+ break;
+ }
+ index++;
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ }
+
+ if (strstr(ItemText, tr("Search term")) == ItemText) {
+ if (!InEditMode(ItemText, tr("Search term"), data.search)) { // show template for a new search
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Templates"));
+ iOnTerm = 1;
+ }
+ } else if (strstr(ItemText, IndentMenuItem(tr("Day of week"))) == ItemText) {
+ if (data.DayOfWeek == 7) {
+ SetHelp(trVDR("Button$Edit"));
+ iOnUserDefDayItem = 1;
+ } else
+ SetHelp(NULL, NULL, tr("Button$Help"));
+ } else if (strstr(ItemText, tr("Use as search timer")) == ItemText) {
+ if (data.useAsSearchTimer == 2) {
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
+ iOnUseAsSearchTimer = 1;
+ } else
+ SetHelp(NULL, NULL, tr("Button$Help"));
+ } else if (strstr(ItemText, IndentMenuItem(tr("Directory"))) == ItemText) {
+ if (!InEditMode(ItemText, IndentMenuItem(tr("Directory")), data.directory))
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Select"));
+ iOnDirectoryItem = 1;
+ } else if (strstr(ItemText, tr("Use channel")) == ItemText && data.useChannel == 2) {
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
+ iOnUseChannelGroups = 1;
+ } else if (strstr(ItemText, IndentMenuItem(tr("Channel group"))) == ItemText) {
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
+ iOnChannelGroup = 1;
+ } else if (strstr(ItemText, tr("Use blacklists")) == ItemText && data.blacklistMode == blacklistsSelection) {
SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
- iOnUseAsSearchTimer = 1;
- }
- else
- SetHelp(NULL, NULL, tr("Button$Help"));
- }
- else if (strstr(ItemText, IndentMenuItem(tr("Directory"))) == ItemText)
- {
- if (!InEditMode(ItemText, IndentMenuItem(tr("Directory")), data.directory))
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Select"));
- iOnDirectoryItem = 1;
- }
- else if (strstr(ItemText, tr("Use channel")) == ItemText && data.useChannel == 2)
- {
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
- iOnUseChannelGroups = 1;
- }
- else if (strstr(ItemText, IndentMenuItem(tr("Channel group"))) == ItemText)
- {
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
- iOnChannelGroup = 1;
- }
- else if (strstr(ItemText, tr("Use blacklists")) == ItemText && data.blacklistMode == blacklistsSelection)
- {
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
- iOnUseBlacklistsSelection = 1;
- }
- else if (strstr(ItemText, IndentMenuItem(tr("Avoid repeats"))) == ItemText)
- {
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
- iOnAvoidRepeats = 1;
- }
- else if (strstr(ItemText, IndentMenuItem(IndentMenuItem(tr("Compare categories")))) == ItemText)
- {
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
- iOnCompareCats = 1;
- }
- else if (iOnExtCatItem)
- {
- if (!InEditMode(ItemText, IndentMenuItem(catname), data.catvalues[iCatIndex]) ||
- SearchExtCats.Get(iCatIndex)->searchmode >= 10)
- SetHelp(NULL, NULL, tr("Button$Help"), iOnExtCatItemBrowsable?tr("Button$Select"):NULL);
- }
- else if (strstr(ItemText, tr("Search term")) != ItemText)
- SetHelp(NULL, NULL, tr("Button$Help"), NULL);
- }
- if (state == osUnknown) {
- if (HasSubMenu())
- return osContinue;
- switch (Key) {
- case kOk:
- if (data.useChannel==1)
- {
- LOCK_CHANNELS_READ;
- const cChannel *ch = Channels->GetByNumber(channelMin);
- if (ch)
- data.channelMin = ch;
- else
- {
- ERROR(tr("*** Invalid Channel ***"));
- break;
- }
- ch = Channels->GetByNumber(channelMax);
- if (ch)
- data.channelMax = ch;
- else
- {
- ERROR(tr("*** Invalid Channel ***"));
- break;
- }
- if (channelMin > channelMax)
- {
- ERROR(tr("Please check channel criteria!"));
- return osContinue;
- }
+ iOnUseBlacklistsSelection = 1;
+ } else if (strstr(ItemText, IndentMenuItem(tr("Avoid repeats"))) == ItemText) {
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
+ iOnAvoidRepeats = 1;
+ } else if (strstr(ItemText, IndentMenuItem(IndentMenuItem(tr("Compare categories")))) == ItemText) {
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
+ iOnCompareCats = 1;
+ } else if (iOnExtCatItem) {
+ if (!InEditMode(ItemText, IndentMenuItem(catname), data.catvalues[iCatIndex]) ||
+ SearchExtCats.Get(iCatIndex)->searchmode >= 10)
+ SetHelp(NULL, NULL, tr("Button$Help"), iOnExtCatItemBrowsable ? tr("Button$Select") : NULL);
+ } else if (strstr(ItemText, tr("Search term")) != ItemText)
+ SetHelp(NULL, NULL, tr("Button$Help"), NULL);
+ }
+ if (state == osUnknown) {
+ if (HasSubMenu())
+ return osContinue;
+ switch (Key) {
+ case kOk:
+ if (data.useChannel == 1) {
+ LOCK_CHANNELS_READ;
+ const cChannel *ch = Channels->GetByNumber(channelMin);
+ if (ch)
+ data.channelMin = ch;
+ else {
+ ERROR(tr("*** Invalid Channel ***"));
+ break;
+ }
+ ch = Channels->GetByNumber(channelMax);
+ if (ch)
+ data.channelMax = ch;
+ else {
+ ERROR(tr("*** Invalid Channel ***"));
+ break;
+ }
+ if (channelMin > channelMax) {
+ ERROR(tr("Please check channel criteria!"));
+ return osContinue;
+ }
}
- if (data.useChannel==2)
- data.channelGroup = strdup(menuitemsChGr[channelGroupNr]);
+ if (data.useChannel == 2)
+ data.channelGroup = strdup(menuitemsChGr[channelGroupNr]);
if ((data.useTitle || data.useSubtitle || data.useDescription) &&
(int(strlen(data.search)) < 3) &&
!Interface->Confirm(tr("Edit$Search text too short - use anyway?")))
- break;
-
- if (searchExt)
- {
- *searchExt = data;
- if (data.DayOfWeek == 7)
- searchExt->DayOfWeek = UserDefDayOfWeek;
-
- // transfer cat selection for 'avoid repeats' back to search
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- searchExt->catvaluesAvoidRepeat = 0;
- while (SearchExtCat)
- {
- if (catarrayAvoidRepeats[index])
- searchExt->catvaluesAvoidRepeat += (1<<index);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
-
- // transfer numeric cat values back to search
- SearchExtCat = SearchExtCats.First();
- index = 0;
- while (SearchExtCat)
- {
- if (SearchExtCat->searchmode >= 10)
- {
- if (searchExt->catvalues[index]) free(searchExt->catvalues[index]);
- msprintf(&searchExt->catvalues[index], "%d", catvaluesNumeric[index]);
- }
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
-
- searchExt->SetContentFilter(useContentDescriptors?contentStringsFlags:NULL);
-
- if (data.blacklistMode == blacklistsSelection)
- {
- searchExt->blacklists.Clear();
- cBlacklistObject* blacklistObj = blacklists.First();
- while(blacklistObj)
- {
- searchExt->blacklists.Add(new cBlacklistObject(blacklistObj->blacklist));
- blacklistObj = blacklists.Next(blacklistObj);
- }
- }
- else
- searchExt->blacklists.Clear();
-
- if (addIfConfirmed)
- {
- cMutexLock SearchExtsLock(&SearchExts);
- searchExt->ID = SearchExts.GetNewID();
- SearchExts.Add(searchExt);
- }
- if (searchExt->useAsSearchTimer && !EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
- {
- cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
- INFO(tr("Search timers activated in setup."));
- }
-
- SearchExts.Save();
- addIfConfirmed = false;
+ break;
+
+ if (searchExt) {
+ *searchExt = data;
+ if (data.DayOfWeek == 7)
+ searchExt->DayOfWeek = UserDefDayOfWeek;
+
+ // transfer cat selection for 'avoid repeats' back to search
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ searchExt->catvaluesAvoidRepeat = 0;
+ while (SearchExtCat) {
+ if (catarrayAvoidRepeats[index])
+ searchExt->catvaluesAvoidRepeat += (1 << index);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+
+ // transfer numeric cat values back to search
+ SearchExtCat = SearchExtCats.First();
+ index = 0;
+ while (SearchExtCat) {
+ if (SearchExtCat->searchmode >= 10) {
+ if (searchExt->catvalues[index]) free(searchExt->catvalues[index]);
+ msprintf(&searchExt->catvalues[index], "%d", catvaluesNumeric[index]);
+ }
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+
+ searchExt->SetContentFilter(useContentDescriptors ? contentStringsFlags : NULL);
+
+ if (data.blacklistMode == blacklistsSelection) {
+ searchExt->blacklists.Clear();
+ cBlacklistObject* blacklistObj = blacklists.First();
+ while (blacklistObj) {
+ searchExt->blacklists.Add(new cBlacklistObject(blacklistObj->blacklist));
+ blacklistObj = blacklists.Next(blacklistObj);
+ }
+ } else
+ searchExt->blacklists.Clear();
+
+ if (addIfConfirmed) {
+ cMutexLock SearchExtsLock(&SearchExts);
+ searchExt->ID = SearchExts.GetNewID();
+ SearchExts.Add(searchExt);
+ }
+ if (searchExt->useAsSearchTimer && !EPGSearchConfig.useSearchTimers) { // enable search timer thread if necessary
+ cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
+ INFO(tr("Search timers activated in setup."));
+ }
+
+ SearchExts.Save();
+ addIfConfirmed = false;
}
return osBack;
- case kRed:
+ case kRed:
if (iOnUserDefDayItem)
- state = AddSubMenu(new cMenuEditDaysOfWeek(&UserDefDayOfWeek));
+ state = AddSubMenu(new cMenuEditDaysOfWeek(&UserDefDayOfWeek));
break;
- case kBlue:
+ case kBlue:
if (iOnDirectoryItem && !InEditMode(ItemText, IndentMenuItem(tr("Directory")), data.directory))
- state = AddSubMenu(new cMenuDirSelect(data.directory));
- if (iOnUseChannelGroups || iOnChannelGroup)
- {
- if (channelGroupName)
- free(channelGroupName);
- channelGroupName = strdup(menuitemsChGr[channelGroupNr]);
- state = AddSubMenu(new cMenuChannelGroups(&channelGroupName));
+ state = AddSubMenu(new cMenuDirSelect(data.directory));
+ if (iOnUseChannelGroups || iOnChannelGroup) {
+ if (channelGroupName)
+ free(channelGroupName);
+ channelGroupName = strdup(menuitemsChGr[channelGroupNr]);
+ state = AddSubMenu(new cMenuChannelGroups(&channelGroupName));
}
if (iOnAvoidRepeats)
- state = AddSubMenu(new cMenuRecsDone(searchExt));
+ state = AddSubMenu(new cMenuRecsDone(searchExt));
if (iOnCompareCats)
- state = AddSubMenu(new cMenuSearchEditCompCats(catarrayAvoidRepeats));
+ state = AddSubMenu(new cMenuSearchEditCompCats(catarrayAvoidRepeats));
if (iOnTerm)
- state = AddSubMenu(new cMenuEPGSearchTemplate(&data, NULL, addIfConfirmed));
+ state = AddSubMenu(new cMenuEPGSearchTemplate(&data, NULL, addIfConfirmed));
if (iOnUseBlacklistsSelection)
- state = AddSubMenu(new cMenuBlacklistsSelection(&blacklists));
+ state = AddSubMenu(new cMenuBlacklistsSelection(&blacklists));
if (iOnExtCatItemBrowsable)
- state = AddSubMenu(new cMenuCatValuesSelect(data.catvalues[iCatIndex], iCatIndex, SearchExtCats.Get(iCatIndex)->searchmode));
- if (iOnUseAsSearchTimer)
- state = AddSubMenu(new cMenuSearchActivSettings(&data));
+ state = AddSubMenu(new cMenuCatValuesSelect(data.catvalues[iCatIndex], iCatIndex, SearchExtCats.Get(iCatIndex)->searchmode));
+ if (iOnUseAsSearchTimer)
+ state = AddSubMenu(new cMenuSearchActivSettings(&data));
break;
- case kGreen:
- state = osContinue;
- break;
- case kYellow:
- case kInfo:
- state = Help();
- break;
- default: break;
- }
- }
- if ((iOnUseChannelGroups || iOnChannelGroup || iOnCompareCats || iOnTerm || iOnExtCatItemBrowsable) && bHadSubMenu && !HasSubMenu()) // return form submenu
- {
- if (iOnTerm)
- {
- if (data.DayOfWeek < 0)
- {
- UserDefDayOfWeek = data.DayOfWeek;
- data.DayOfWeek = 7;
- }
- if (data.useChannel == 1)
- {
- channelMin = data.channelMin->Number();
- channelMax = data.channelMax->Number();
- }
- if (data.useChannel == 2)
- {
- channelGroupNr = ChannelGroups.GetIndex(data.channelGroup);
- channelGroupName = strdup(data.channelGroup);
- }
- if (SearchExtCats.Count() > 0)
- {
+ case kGreen:
+ state = osContinue;
+ break;
+ case kYellow:
+ case kInfo:
+ state = Help();
+ break;
+ default:
+ break;
+ }
+ }
+ if ((iOnUseChannelGroups || iOnChannelGroup || iOnCompareCats || iOnTerm || iOnExtCatItemBrowsable) && bHadSubMenu && !HasSubMenu()) { // return form submenu
+ if (iOnTerm) {
+ if (data.DayOfWeek < 0) {
+ UserDefDayOfWeek = data.DayOfWeek;
+ data.DayOfWeek = 7;
+ }
+ if (data.useChannel == 1) {
+ channelMin = data.channelMin->Number();
+ channelMax = data.channelMax->Number();
+ }
+ if (data.useChannel == 2) {
+ channelGroupNr = ChannelGroups.GetIndex(data.channelGroup);
+ channelGroupName = strdup(data.channelGroup);
+ }
+ if (SearchExtCats.Count() > 0) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ catarrayAvoidRepeats[index] = (data.catvaluesAvoidRepeat & (1 << index)) ? 1 : 0;
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+ }
+ }
+ if (iOnExtCatItemBrowsable && SearchExtCats.Count() > 0) {
cSearchExtCat *SearchExtCat = SearchExtCats.First();
int index = 0;
- while (SearchExtCat)
- {
- catarrayAvoidRepeats[index] = (data.catvaluesAvoidRepeat & (1<<index))?1:0;
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
+ while (SearchExtCat) {
+ if (SearchExtCat->searchmode >= 10)
+ catvaluesNumeric[index] = atoi(data.catvalues[index]);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
}
- }
- }
- if (iOnExtCatItemBrowsable && SearchExtCats.Count() > 0)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- if (SearchExtCat->searchmode >= 10)
- catvaluesNumeric[index] = atoi(data.catvalues[index]);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- }
- Set();
- Display();
- }
- return state;
+ }
+ Set();
+ Display();
+ }
+ return state;
}
// --- cMenuEditDaysOfWeek --------------------------------------------------------
cMenuEditDaysOfWeek::cMenuEditDaysOfWeek(int* DaysOfWeek, int Offset, bool Negate)
-:cOsdMenu(tr("Edit user-defined days of week"),30)
+ : cOsdMenu(tr("Edit user-defined days of week"), 30)
{
- SetMenuCategory(mcPlugin);
- int i=0;
- offset = Offset;
- negate = Negate;
- pDaysOfWeek = DaysOfWeek;
+ SetMenuCategory(mcPlugin);
+ int i = 0;
+ offset = Offset;
+ negate = Negate;
+ pDaysOfWeek = DaysOfWeek;
- if (negate)
- *pDaysOfWeek = -*pDaysOfWeek;
+ if (negate)
+ *pDaysOfWeek = -*pDaysOfWeek;
- for(i=0; i<7; i++)
- Days[(i+offset)%7]=((*pDaysOfWeek) & (int)pow(2,i))?1:0;
- for(i=0; i<7; i++)
- Add(new cMenuEditBoolItem( WeekDayName((i+1)%7), &Days[(i+1)%7], trVDR("no"), trVDR("yes")));
+ for (i = 0; i < 7; i++)
+ Days[(i + offset) % 7] = ((*pDaysOfWeek) & (int)pow(2, i)) ? 1 : 0;
+ for (i = 0; i < 7; i++)
+ Add(new cMenuEditBoolItem(WeekDayName((i + 1) % 7), &Days[(i + 1) % 7], trVDR("no"), trVDR("yes")));
- SetHelp(NULL);
+ SetHelp(NULL);
}
eOSState cMenuEditDaysOfWeek::ProcessKey(eKeys Key)
{
- if (Key == kBack && negate)
- *pDaysOfWeek = -*pDaysOfWeek;
+ if (Key == kBack && negate)
+ *pDaysOfWeek = -*pDaysOfWeek;
- eOSState state = cOsdMenu::ProcessKey(Key);
+ eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown) {
- switch (Key) {
- case kOk:
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk:
*pDaysOfWeek = 0;
- for(int i=0; i<7; i++)
- *pDaysOfWeek += Days[i]?(int)pow(2,(i+7-offset)%7):0;
+ for (int i = 0; i < 7; i++)
+ *pDaysOfWeek += Days[i] ? (int)pow(2, (i + 7 - offset) % 7) : 0;
if (negate)
- *pDaysOfWeek = -*pDaysOfWeek;
+ *pDaysOfWeek = -*pDaysOfWeek;
state = osBack;
break;
- default: break;
- }
- }
- return state;
+ default:
+ break;
+ }
+ }
+ return state;
}
// --- cMenuSearchEditCompCats --------------------------------------------------------
cMenuSearchEditCompCats::cMenuSearchEditCompCats(int* catarrayAvoidRepeats)
-:cOsdMenu(tr("Compare categories"),30)
+ : cOsdMenu(tr("Compare categories"), 30)
{
- SetMenuCategory(mcPlugin);
- search_catarrayAvoidRepeats = catarrayAvoidRepeats;
- edit_catarrayAvoidRepeats = (int*) malloc(SearchExtCats.Count() * sizeof(int));
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- edit_catarrayAvoidRepeats[index] = catarrayAvoidRepeats[index];
- cString menutext = cString::sprintf("%s %s", tr("Compare"), SearchExtCat->menuname);
- Add(new cMenuEditBoolItem(menutext, &edit_catarrayAvoidRepeats[index], trVDR("no"), trVDR("yes")));
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
+ SetMenuCategory(mcPlugin);
+ search_catarrayAvoidRepeats = catarrayAvoidRepeats;
+ edit_catarrayAvoidRepeats = (int*) malloc(SearchExtCats.Count() * sizeof(int));
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ edit_catarrayAvoidRepeats[index] = catarrayAvoidRepeats[index];
+ cString menutext = cString::sprintf("%s %s", tr("Compare"), SearchExtCat->menuname);
+ Add(new cMenuEditBoolItem(menutext, &edit_catarrayAvoidRepeats[index], trVDR("no"), trVDR("yes")));
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
}
cMenuSearchEditCompCats::~cMenuSearchEditCompCats()
{
- free(edit_catarrayAvoidRepeats);
+ free(edit_catarrayAvoidRepeats);
}
eOSState cMenuSearchEditCompCats::ProcessKey(eKeys Key)
{
- eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown) {
- switch (Key) {
- case kOk:
- {
+ eOSState state = cOsdMenu::ProcessKey(Key);
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk: {
cSearchExtCat *SearchExtCat = SearchExtCats.First();
int index = 0;
- while (SearchExtCat)
- {
- search_catarrayAvoidRepeats[index] = edit_catarrayAvoidRepeats[index];
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
+ while (SearchExtCat) {
+ search_catarrayAvoidRepeats[index] = edit_catarrayAvoidRepeats[index];
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
}
- }
- state = osBack;
- break;
- default: break;
- }
- }
- return state;
+ }
+ state = osBack;
+ break;
+ default:
+ break;
+ }
+ }
+ return state;
}
// --- cMenuBlacklistsSelection --------------------------------------------------------
cMenuBlacklistsSelection::cMenuBlacklistsSelection(cList<cBlacklistObject>* pBlacklists)
-:cOsdMenu(tr("Select blacklists"),30)
+ : cOsdMenu(tr("Select blacklists"), 30)
{
- SetMenuCategory(mcPlugin);
- blacklists = pBlacklists;
- blacklistsSel = new int[Blacklists.Count()];
- cMutexLock BlacklistLock(&Blacklists);
- cBlacklist* blacklist = Blacklists.First();
- int index = 0;
- while(blacklist)
- {
- blacklistsSel[index] = false;
- cBlacklistObject* blacklistObjSel = blacklists->First();
- while(blacklistObjSel)
- {
- if (blacklistObjSel->blacklist->ID == blacklist->ID)
- {
- blacklistsSel[index] = true;
- break;
- }
- blacklistObjSel = blacklists->Next(blacklistObjSel);
- }
- blacklist = Blacklists.Next(blacklist);
- index++;
- }
-
- SetHelp(tr("Button$Invert selection"), tr("Button$All yes"), tr("Button$All no"), tr("Button$Setup"));
- Set();
+ SetMenuCategory(mcPlugin);
+ blacklists = pBlacklists;
+ blacklistsSel = new int[Blacklists.Count()];
+ cMutexLock BlacklistLock(&Blacklists);
+ cBlacklist* blacklist = Blacklists.First();
+ int index = 0;
+ while (blacklist) {
+ blacklistsSel[index] = false;
+ cBlacklistObject* blacklistObjSel = blacklists->First();
+ while (blacklistObjSel) {
+ if (blacklistObjSel->blacklist->ID == blacklist->ID) {
+ blacklistsSel[index] = true;
+ break;
+ }
+ blacklistObjSel = blacklists->Next(blacklistObjSel);
+ }
+ blacklist = Blacklists.Next(blacklist);
+ index++;
+ }
+
+ SetHelp(tr("Button$Invert selection"), tr("Button$All yes"), tr("Button$All no"), tr("Button$Setup"));
+ Set();
}
cMenuBlacklistsSelection::~cMenuBlacklistsSelection()
{
- if (blacklistsSel) delete [] blacklistsSel;
+ if (blacklistsSel) delete [] blacklistsSel;
}
// --- cMenuBlacklistsSelectionItem ----------------------------------------------------------
-class cMenuBlacklistsSelectionItem : public cMenuEditBoolItem {
- const char* name;
- public:
- cMenuBlacklistsSelectionItem(const char *Name, int *Value, const char *FalseString = NULL, const char *TrueString = NULL):
- cMenuEditBoolItem(Name, Value, FalseString, TrueString) { name = Name; }
- int Compare(const cListObject &ListObject) const
- {
- cMenuBlacklistsSelectionItem *p = (cMenuBlacklistsSelectionItem*)&ListObject;
- return strcasecmp(name, p->name);
- }
+class cMenuBlacklistsSelectionItem : public cMenuEditBoolItem
+{
+ const char* name;
+public:
+ cMenuBlacklistsSelectionItem(const char *Name, int *Value, const char *FalseString = NULL, const char *TrueString = NULL):
+ cMenuEditBoolItem(Name, Value, FalseString, TrueString) {
+ name = Name;
+ }
+ int Compare(const cListObject &ListObject) const {
+ cMenuBlacklistsSelectionItem *p = (cMenuBlacklistsSelectionItem*)&ListObject;
+ return strcasecmp(name, p->name);
+ }
};
void cMenuBlacklistsSelection::Set()
{
- int current = Current();
- Clear();
- cMutexLock BlacklistLock(&Blacklists);
- cBlacklist* blacklist = Blacklists.First();
- int index = 0;
- while(blacklist)
- {
- Add(new cMenuBlacklistsSelectionItem(blacklist->search, &blacklistsSel[index], trVDR("no"), trVDR("yes")));
- blacklist = Blacklists.Next(blacklist);
- index++;
- }
- SetCurrent(Get(current));
- Sort();
+ int current = Current();
+ Clear();
+ cMutexLock BlacklistLock(&Blacklists);
+ cBlacklist* blacklist = Blacklists.First();
+ int index = 0;
+ while (blacklist) {
+ Add(new cMenuBlacklistsSelectionItem(blacklist->search, &blacklistsSel[index], trVDR("no"), trVDR("yes")));
+ blacklist = Blacklists.Next(blacklist);
+ index++;
+ }
+ SetCurrent(Get(current));
+ Sort();
}
eOSState cMenuBlacklistsSelection::ProcessKey(eKeys Key)
{
- bool bHadSubMenu = HasSubMenu();
+ bool bHadSubMenu = HasSubMenu();
- eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown) {
- switch (Key) {
- case kOk:
- {
+ eOSState state = cOsdMenu::ProcessKey(Key);
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk: {
cMutexLock BlacklistLock(&Blacklists);
blacklists->Clear();
cBlacklist* blacklist = Blacklists.First();
int index = 0;
- while(blacklist)
- {
- if (blacklistsSel[index++])
- blacklists->Add(new cBlacklistObject(blacklist));
- blacklist = Blacklists.Next(blacklist);
+ while (blacklist) {
+ if (blacklistsSel[index++])
+ blacklists->Add(new cBlacklistObject(blacklist));
+ blacklist = Blacklists.Next(blacklist);
}
- }
- state = osBack;
- break;
- case kRed:
- case kGreen:
- case kYellow:
- {
+ }
+ state = osBack;
+ break;
+ case kRed:
+ case kGreen:
+ case kYellow: {
cMutexLock BlacklistLock(&Blacklists);
cBlacklist* blacklist = Blacklists.First();
int index = 0;
- while(blacklist)
- {
- blacklistsSel[index] = (Key == kGreen?1:(Key == kRed?1-blacklistsSel[index]:0));
- blacklist = Blacklists.Next(blacklist);
- index++;
+ while (blacklist) {
+ blacklistsSel[index] = (Key == kGreen ? 1 : (Key == kRed ? 1 - blacklistsSel[index] : 0));
+ blacklist = Blacklists.Next(blacklist);
+ index++;
}
Set();
Display();
return osContinue;
- }
- break;
- case kBlue:
+ }
+ break;
+ case kBlue:
state = AddSubMenu(new cMenuBlacklists);
break;
- default: break;
- }
- }
- if (bHadSubMenu && !HasSubMenu()) // return form submenu
- {
- Clear();
- delete [] blacklistsSel;
- blacklistsSel = new int[Blacklists.Count()];
- cMutexLock BlacklistLock(&Blacklists);
- cBlacklist* blacklist = Blacklists.First();
- int index = 0;
- while(blacklist)
- {
- blacklistsSel[index] = false;
- cBlacklistObject* blacklistObjSel = blacklists->First();
- while(blacklistObjSel)
- {
- if (blacklistObjSel->blacklist->ID == blacklist->ID)
- {
- blacklistsSel[index] = true;
- break;
+ default:
+ break;
+ }
+ }
+ if (bHadSubMenu && !HasSubMenu()) { // return form submenu
+ Clear();
+ delete [] blacklistsSel;
+ blacklistsSel = new int[Blacklists.Count()];
+ cMutexLock BlacklistLock(&Blacklists);
+ cBlacklist* blacklist = Blacklists.First();
+ int index = 0;
+ while (blacklist) {
+ blacklistsSel[index] = false;
+ cBlacklistObject* blacklistObjSel = blacklists->First();
+ while (blacklistObjSel) {
+ if (blacklistObjSel->blacklist->ID == blacklist->ID) {
+ blacklistsSel[index] = true;
+ break;
+ }
+ blacklistObjSel = blacklists->Next(blacklistObjSel);
}
- blacklistObjSel = blacklists->Next(blacklistObjSel);
- }
- blacklist = Blacklists.Next(blacklist);
- index++;
- }
- Set();
- Display();
- }
-
- return state;
+ blacklist = Blacklists.Next(blacklist);
+ index++;
+ }
+ Set();
+ Display();
+ }
+
+ return state;
}
// --- cMenuCatValuesSelect --------------------------------------------------------
cMenuCatValuesSelect::cMenuCatValuesSelect(char* CatValues, int CatIndex, int SearchMode)
-:cOsdMenu(tr("Values for EPG category"), 1, 40)
+ : cOsdMenu(tr("Values for EPG category"), 1, 40)
{
- SetMenuCategory(mcPlugin);
-
- catValues = CatValues;
- catIndex = CatIndex;
- searchMode = SearchMode;
- cSearchExtCat* SearchExtCat = SearchExtCats.Get(catIndex);
- if (SearchExtCat)
- {
- sel_cats.assign(SearchExtCat->nvalues, false);
- for(int i=0; i<SearchExtCat->nvalues; i++)
- {
- char *pstrSearchToken, *pptr;
- char *pstrSearch=strdup(catValues);
- pstrSearchToken=strtok_r(pstrSearch, ",;|~", &pptr);
- while(pstrSearchToken)
- {
- if(SearchExtCat->values[i] && strcmp(SearchExtCat->values[i], skipspace(pstrSearchToken))==0)
- sel_cats[i] = true;
- pstrSearchToken=strtok_r(NULL, ",;|~", &pptr);
- }
- free(pstrSearch);
- }
- }
- Set();
- SetHelp(trVDR("Button$On/Off"), NULL, NULL, tr("Button$Apply"));
+ SetMenuCategory(mcPlugin);
+
+ catValues = CatValues;
+ catIndex = CatIndex;
+ searchMode = SearchMode;
+ cSearchExtCat* SearchExtCat = SearchExtCats.Get(catIndex);
+ if (SearchExtCat) {
+ sel_cats.assign(SearchExtCat->nvalues, false);
+ for (int i = 0; i < SearchExtCat->nvalues; i++) {
+ char *pstrSearchToken, *pptr;
+ char *pstrSearch = strdup(catValues);
+ pstrSearchToken = strtok_r(pstrSearch, ",;|~", &pptr);
+ while (pstrSearchToken) {
+ if (SearchExtCat->values[i] && strcmp(SearchExtCat->values[i], skipspace(pstrSearchToken)) == 0)
+ sel_cats[i] = true;
+ pstrSearchToken = strtok_r(NULL, ",;|~", &pptr);
+ }
+ free(pstrSearch);
+ }
+ }
+ Set();
+ SetHelp(trVDR("Button$On/Off"), NULL, NULL, tr("Button$Apply"));
}
void cMenuCatValuesSelect::Set()
{
- int current = Current();
- int selCount = 0;
- Clear();
-
- string SearchMode = string(tr("Search mode")) + ": ";
- if (searchMode == 0)
- SearchMode += tr("phrase");
- else if (searchMode == 1)
- SearchMode += tr("all words");
- else if (searchMode == 2)
- SearchMode += tr("at least one word");
- else if (searchMode == 3)
- SearchMode += tr("match exactly");
- else if (searchMode == 4)
- SearchMode += tr("regular expression");
- else if (searchMode == 10)
- SearchMode += tr("less");
- else if (searchMode == 11)
- SearchMode += tr("less or equal");
- else if (searchMode == 12)
- SearchMode += tr("greater");
- else if (searchMode == 13)
- SearchMode += tr("greater or equal");
- else if (searchMode == 14)
- SearchMode += tr("equal");
- else if (searchMode == 15)
- SearchMode += tr("not equal");
- cOsdItem* sItem = new cOsdItem(SearchMode.c_str());
- Add(sItem);
- sItem->SetSelectable(false);
-
- cSearchExtCat* SearchExtCat = SearchExtCats.Get(catIndex);
- if (SearchExtCat)
- {
- for(int i=0; i<SearchExtCat->nvalues; i++)
- {
- cString entry = cString::sprintf("%c\t%s", sel_cats[i]?'*':' ', SearchExtCat->values[i]);
- if (sel_cats[i]) selCount++;
- Add(new cOsdItem(entry));
- }
- }
- SetCurrent(Get(current));
- if (SearchExtCat)
- {
+ int current = Current();
+ int selCount = 0;
+ Clear();
+
+ string SearchMode = string(tr("Search mode")) + ": ";
+ if (searchMode == 0)
+ SearchMode += tr("phrase");
+ else if (searchMode == 1)
+ SearchMode += tr("all words");
+ else if (searchMode == 2)
+ SearchMode += tr("at least one word");
+ else if (searchMode == 3)
+ SearchMode += tr("match exactly");
+ else if (searchMode == 4)
+ SearchMode += tr("regular expression");
+ else if (searchMode == 10)
+ SearchMode += tr("less");
+ else if (searchMode == 11)
+ SearchMode += tr("less or equal");
+ else if (searchMode == 12)
+ SearchMode += tr("greater");
+ else if (searchMode == 13)
+ SearchMode += tr("greater or equal");
+ else if (searchMode == 14)
+ SearchMode += tr("equal");
+ else if (searchMode == 15)
+ SearchMode += tr("not equal");
+ cOsdItem* sItem = new cOsdItem(SearchMode.c_str());
+ Add(sItem);
+ sItem->SetSelectable(false);
+
+ cSearchExtCat* SearchExtCat = SearchExtCats.Get(catIndex);
+ if (SearchExtCat) {
+ for (int i = 0; i < SearchExtCat->nvalues; i++) {
+ cString entry = cString::sprintf("%c\t%s", sel_cats[i] ? '*' : ' ', SearchExtCat->values[i]);
+ if (sel_cats[i]) selCount++;
+ Add(new cOsdItem(entry));
+ }
+ }
+ SetCurrent(Get(current));
+ if (SearchExtCat) {
cString title = cString::sprintf("%s (%d/%d)", tr("Values for EPG category"), selCount, SearchExtCat->nvalues);
if (*title) SetTitle(title);
- }
- Display();
+ }
+ Display();
}
eOSState cMenuCatValuesSelect::ProcessKey(eKeys Key)
{
- eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown) {
- switch (Key) {
- case kOk:
- case kRed:
- if (Current()>0)
- {
- cSearchExtCat* SearchExtCat = SearchExtCats.Get(catIndex);
- if (SearchExtCat && SearchExtCat->searchmode >= 10 && catValues) // only one numeric value, so jump back
- {
- strcpy(catValues, SearchExtCat->values[Current()-1]);
- state = osBack;
- }
- else
- {
- sel_cats[Current()-1] = !sel_cats[Current()-1];
- Set();
- Display();
- }
+ eOSState state = cOsdMenu::ProcessKey(Key);
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk:
+ case kRed:
+ if (Current() > 0) {
+ cSearchExtCat* SearchExtCat = SearchExtCats.Get(catIndex);
+ if (SearchExtCat && SearchExtCat->searchmode >= 10 && catValues) { // only one numeric value, so jump back
+ strcpy(catValues, SearchExtCat->values[Current() - 1]);
+ state = osBack;
+ } else {
+ sel_cats[Current() - 1] = !sel_cats[Current() - 1];
+ Set();
+ Display();
+ }
}
break;
- case kBlue:
- {
+ case kBlue: {
*catValues = 0;
cSearchExtCat* SearchExtCat = SearchExtCats.Get(catIndex);
- if (SearchExtCat)
- {
- for(int i=0; i<SearchExtCat->nvalues; i++)
- {
- if (sel_cats[i])
- {
- if (*catValues)
- strcat(catValues, ", ");
- strcat(catValues, SearchExtCat->values[i]);
- }
- }
+ if (SearchExtCat) {
+ for (int i = 0; i < SearchExtCat->nvalues; i++) {
+ if (sel_cats[i]) {
+ if (*catValues)
+ strcat(catValues, ", ");
+ strcat(catValues, SearchExtCat->values[i]);
+ }
+ }
}
state = osBack;
break;
- }
- default: break;
- }
- }
- return state;
+ }
+ default:
+ break;
+ }
+ }
+ return state;
}
// --- cMenuSearchActivSettings --------------------------------------------------------
cMenuSearchActivSettings::cMenuSearchActivSettings(cSearchExt *SearchExt)
-:cOsdMenu(tr("Activation of search timer"), 25)
+ : cOsdMenu(tr("Activation of search timer"), 25)
{
- SetMenuCategory(mcPlugin);
+ SetMenuCategory(mcPlugin);
- searchExt = SearchExt;
- if (searchExt)
- {
- Add(new cMenuEditDateItem(tr("First day"), &searchExt->useAsSearchTimerFrom, NULL));
- Add(new cMenuEditDateItem(tr("Last day"), &searchExt->useAsSearchTimerTil, NULL));
+ searchExt = SearchExt;
+ if (searchExt) {
+ Add(new cMenuEditDateItem(tr("First day"), &searchExt->useAsSearchTimerFrom, NULL));
+ Add(new cMenuEditDateItem(tr("Last day"), &searchExt->useAsSearchTimerTil, NULL));
}
}
eOSState cMenuSearchActivSettings::ProcessKey(eKeys Key)
{
- eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown) {
- switch (Key) {
- case kOk:
- state = osBack;
- break;
- default: break;
- }
- }
- return state;
+ eOSState state = cOsdMenu::ProcessKey(Key);
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk:
+ state = osBack;
+ break;
+ default:
+ break;
+ }
+ }
+ return state;
}
diff --git a/menu_searchedit.h b/menu_searchedit.h
index f026dac..21ed188 100644
--- a/menu_searchedit.h
+++ b/menu_searchedit.h
@@ -30,71 +30,75 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
// --- cMenuEditSearchExt --------------------------------------------------------
-class cMenuEditSearchExt : public cOsdMenu {
+class cMenuEditSearchExt : public cOsdMenu
+{
protected:
- cSearchExt *searchExt;
- cSearchExt data;
- int channelMin;
- int channelMax;
- bool addIfConfirmed;
- int UserDefDayOfWeek;
- int channelGroupNr;
- char* channelGroupName;
- char** menuitemsChGr;
- int* catarrayAvoidRepeats;
- int* catvaluesNumeric;
- cList<cBlacklistObject> blacklists;
-
- char *SearchModes[6];
- char *DaysOfWeek[8];
- char *UseChannelSel[4];
- char *SearchTimerModes[6];
- char *BlacklistModes[4];
- char *DelModes[3];
- char *SearchActiveModes[3];
- char *CompareSubtitleModes[2];
- char *CompareDateModes[4];
- std::vector<int> contentStringIDs;
- int useContentDescriptors;
- int *contentStringsFlags;
- bool templateMode;
- std::vector<const char*> helpTexts;
- void AddHelp(const char* helpText);
+ cSearchExt *searchExt;
+ cSearchExt data;
+ int channelMin;
+ int channelMax;
+ bool addIfConfirmed;
+ int UserDefDayOfWeek;
+ int channelGroupNr;
+ char* channelGroupName;
+ char** menuitemsChGr;
+ int* catarrayAvoidRepeats;
+ int* catvaluesNumeric;
+ cList<cBlacklistObject> blacklists;
+
+ char *SearchModes[6];
+ char *DaysOfWeek[8];
+ char *UseChannelSel[4];
+ char *SearchTimerModes[6];
+ char *BlacklistModes[4];
+ char *DelModes[3];
+ char *SearchActiveModes[3];
+ char *CompareSubtitleModes[2];
+ char *CompareDateModes[4];
+ std::vector<int> contentStringIDs;
+ int useContentDescriptors;
+ int *contentStringsFlags;
+ bool templateMode;
+ std::vector<const char*> helpTexts;
+ void AddHelp(const char* helpText);
public:
- cMenuEditSearchExt(cSearchExt *SearchExt, bool New = false, bool Template = false, bool FromEPG = false);
- virtual ~cMenuEditSearchExt();
- virtual void Set();
- virtual eOSState ProcessKey(eKeys Key);
- eOSState Help();
- };
+ cMenuEditSearchExt(cSearchExt *SearchExt, bool New = false, bool Template = false, bool FromEPG = false);
+ virtual ~cMenuEditSearchExt();
+ virtual void Set();
+ virtual eOSState ProcessKey(eKeys Key);
+ eOSState Help();
+};
// --- cMenuEditDaysOfWeek --------------------------------------------------------
-class cMenuEditDaysOfWeek : public cOsdMenu {
+class cMenuEditDaysOfWeek : public cOsdMenu
+{
private:
- int* pDaysOfWeek;
- int Days[7];
- int offset;
- bool negate;
+ int* pDaysOfWeek;
+ int Days[7];
+ int offset;
+ bool negate;
public:
- cMenuEditDaysOfWeek(int* DaysOfWeek, int Offset=0, bool Negate = true);
- virtual eOSState ProcessKey(eKeys Key);
- };
+ cMenuEditDaysOfWeek(int* DaysOfWeek, int Offset = 0, bool Negate = true);
+ virtual eOSState ProcessKey(eKeys Key);
+};
// --- cMenuSearchEditCompCats --------------------------------------------------------
-class cMenuSearchEditCompCats : public cOsdMenu {
- private:
+class cMenuSearchEditCompCats : public cOsdMenu
+{
+private:
int* search_catarrayAvoidRepeats;
int* edit_catarrayAvoidRepeats;
public:
- cMenuSearchEditCompCats(int* catarrayAvoidRepeats);
- ~cMenuSearchEditCompCats();
- eOSState ProcessKey(eKeys Key);
- };
+ cMenuSearchEditCompCats(int* catarrayAvoidRepeats);
+ ~cMenuSearchEditCompCats();
+ eOSState ProcessKey(eKeys Key);
+};
// --- cMenuBlacklistsSelection --------------------------------------------------------
-class cMenuBlacklistsSelection : public cOsdMenu {
- private:
+class cMenuBlacklistsSelection : public cOsdMenu
+{
+private:
int* blacklistsSel;
cList<cBlacklistObject>* blacklists;
public:
@@ -105,26 +109,28 @@ public:
};
// --- cMenuCatValuesSelect --------------------------------------------------------
-class cMenuCatValuesSelect : public cOsdMenu {
- private:
+class cMenuCatValuesSelect : public cOsdMenu
+{
+private:
char* catValues;
int catIndex;
int searchMode;
std::vector<bool> sel_cats;
public:
- cMenuCatValuesSelect(char* CatValues, int CatIndex, int SearchMode);
- void Set();
- eOSState ProcessKey(eKeys Key);
- };
+ cMenuCatValuesSelect(char* CatValues, int CatIndex, int SearchMode);
+ void Set();
+ eOSState ProcessKey(eKeys Key);
+};
// --- cMenuSearchActivSettings --------------------------------------------------------
-class cMenuSearchActivSettings : public cOsdMenu {
- private:
- cSearchExt *searchExt;
+class cMenuSearchActivSettings : public cOsdMenu
+{
+private:
+ cSearchExt *searchExt;
public:
- cMenuSearchActivSettings(cSearchExt *SearchExt);
- eOSState ProcessKey(eKeys Key);
- };
+ cMenuSearchActivSettings(cSearchExt *SearchExt);
+ eOSState ProcessKey(eKeys Key);
+};
#endif
diff --git a/menu_searchresults.c b/menu_searchresults.c
index fb03441..d4d836c 100644
--- a/menu_searchresults.c
+++ b/menu_searchresults.c
@@ -47,7 +47,7 @@ extern bool isUTF8;
static int CompareRecording(const void *p1, const void *p2)
{
- return (int)((*(cRecording **)p1)->Start() - (*(cRecording **)p2)->Start());
+ return (int)((*(cRecording **)p1)->Start() - (*(cRecording **)p2)->Start());
}
// --- cMenuSearchResultsItem -------------------------------------------------------
@@ -55,143 +55,134 @@ cMenuSearchResultsItem::cMenuSearchResultsItem(const cEvent *EventInfo, bool Epi
bool PreviewTimer, cMenuTemplate* MenuTemplate,
const cSearchExt* Search)
{
- fileName = NULL;
- event = EventInfo;
- timerMatch = tmNone;
- episodeOnly = EpisodeOnly;
- previewTimer = PreviewTimer;
- menuTemplate = MenuTemplate?MenuTemplate:cTemplFile::GetTemplateByName("MenuSearchResults");
- search = Search;
- inSwitchList = false;
- timerActive = false;
- Update(true);
+ fileName = NULL;
+ event = EventInfo;
+ timerMatch = tmNone;
+ episodeOnly = EpisodeOnly;
+ previewTimer = PreviewTimer;
+ menuTemplate = MenuTemplate ? MenuTemplate : cTemplFile::GetTemplateByName("MenuSearchResults");
+ search = Search;
+ inSwitchList = false;
+ timerActive = false;
+ Update(true);
}
bool cMenuSearchResultsItem::Update(bool Force)
{
- if (!menuTemplate)
- return false;
-
- bool result = false;
-
- eTimerMatch OldTimerMatch = timerMatch;
- bool OldInSwitchList = inSwitchList;
- bool OldtimerActive = timerActive;
- bool hasMatch = false;
- const cTimer* timer = NULL;
- LOCK_TIMERS_READ;
- if (event) timer = Timers->GetMatch(event, &timerMatch);
- if (event) inSwitchList = (SwitchTimers.InSwitchList(event)!=NULL);
- if (timer) hasMatch = true;
- if (timer) timerActive = timer->HasFlags(tfActive);
-
- if (Force || timerMatch != OldTimerMatch || inSwitchList != OldInSwitchList || timerActive != OldtimerActive)
- {
- char t[Utf8BufSize(2)]="",v[Utf8BufSize(2)]="",r[Utf8BufSize(2)]="";
- char szStatus[Utf8BufSize(4)] = "";
- if (EPGSearchConfig.WarEagle)
- {
- if (!isUTF8)
- {
- t[0] = event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? ICON_REC : (timerActive ? ICON_CLOCK : ICON_TIMER_INACT)) : (timerActive ? ICON_CLOCK_HALF : ' ') : ' ';
- t[1] = '\0';
- v[0] = event && event->Vps() && (event->Vps() - event->StartTime()) ? ICON_VPS : ' ';
- v[1] = '\0';
- r[0] = event && event->IsRunning() ? ICON_RUNNING : ' ';
- r[1] = '\0';
-
- }
- else
- {
+ if (!menuTemplate)
+ return false;
+
+ bool result = false;
+
+ eTimerMatch OldTimerMatch = timerMatch;
+ bool OldInSwitchList = inSwitchList;
+ bool OldtimerActive = timerActive;
+ bool hasMatch = false;
+ const cTimer* timer = NULL;
+ LOCK_TIMERS_READ;
+ if (event) timer = Timers->GetMatch(event, &timerMatch);
+ if (event) inSwitchList = (SwitchTimers.InSwitchList(event) != NULL);
+ if (timer) hasMatch = true;
+ if (timer) timerActive = timer->HasFlags(tfActive);
+
+ if (Force || timerMatch != OldTimerMatch || inSwitchList != OldInSwitchList || timerActive != OldtimerActive) {
+ char t[Utf8BufSize(2)] = "", v[Utf8BufSize(2)] = "", r[Utf8BufSize(2)] = "";
+ char szStatus[Utf8BufSize(4)] = "";
+ if (EPGSearchConfig.WarEagle) {
+ if (!isUTF8) {
+ t[0] = event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? ICON_REC : (timerActive ? ICON_CLOCK : ICON_TIMER_INACT)) : (timerActive ? ICON_CLOCK_HALF : ' ') : ' ';
+ t[1] = '\0';
+ v[0] = event && event->Vps() && (event->Vps() - event->StartTime()) ? ICON_VPS : ' ';
+ v[1] = '\0';
+ r[0] = event && event->IsRunning() ? ICON_RUNNING : ' ';
+ r[1] = '\0';
+
+ } else {
#if defined(__GNUC__) && __GNUC__ < 3 && __GNUC_MINOR__ < 96
#else
- sprintf(t, "%s", (event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? ICON_REC_UTF8 : (timerActive ? ICON_CLOCK_UTF8 : ICON_TIMER_INACT_UTF8)) : (timerActive ? ICON_CLOCK_HALF_UTF8: " ") : " "));
- sprintf(v, "%s", event && event->Vps() && (event->Vps() - event->StartTime()) ? ICON_VPS_UTF8 : " ");
- sprintf(r, "%s", (event && event->IsRunning() ? ICON_RUNNING_UTF8 : " "));
+ sprintf(t, "%s", (event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? ICON_REC_UTF8 : (timerActive ? ICON_CLOCK_UTF8 : ICON_TIMER_INACT_UTF8)) : (timerActive ? ICON_CLOCK_HALF_UTF8 : " ") : " "));
+ sprintf(v, "%s", event && event->Vps() && (event->Vps() - event->StartTime()) ? ICON_VPS_UTF8 : " ");
+ sprintf(r, "%s", (event && event->IsRunning() ? ICON_RUNNING_UTF8 : " "));
#endif
- }
- }
- else
- {
- t[0] = event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? 'R' : (timerActive ? 'T' : 'i')) : (timerActive ? 't' :' ') : ' ';
- t[1] = '\0';
- v[0] = event && event->Vps() && (event->Vps() - event->StartTime()) ? 'V' : ' ';
- v[1] = '\0';
- r[0] = event && event->IsRunning() ? '*' : ' ';
- r[1] = '\0';
- }
- if (event && inSwitchList)
- {
- cSwitchTimer* s = SwitchTimers.InSwitchList(event);
- t[0] = (s && s->mode==1)?'s':'S';
- }
- if (t[0] != 'T' && previewTimer)
- t[0] = 'P';
-
- strcpy(szStatus, t);
- strcat(szStatus, v);
- strcat(szStatus, r);
-
- char* buffer = strdup(menuTemplate->MenuTemplate());
- strreplace(buffer, '|', '\t');
-
- if (!strcasestr(buffer, "%subtitle%") && cTemplFile::GetTemplateByName("MenuFavorites") != menuTemplate)
- // make sure, there is a subtitle
- buffer = strreplacei(buffer, "%title%", "%title% ~ %subtitle%");
- if (episodeOnly)
- buffer = strreplacei(buffer, "%title%", "");
-
- // parse the epxression and evaluate it
- cVarExpr varExpr(buffer);
- char* tmp = strdup(varExpr.Evaluate(event).c_str());
- free(buffer);
- buffer = tmp;
-
- buffer = strreplacei(buffer, "$status$", szStatus);
- buffer = strreplacei(buffer, "$t_status$", t);
- buffer = strreplacei(buffer, "$v_status$", v);
- buffer = strreplacei(buffer, "$r_status$", r);
-
- buffer = FixSeparators(buffer, '~');
- buffer = FixSeparators(buffer, ':');
- buffer = FixSeparators(buffer, '-');
-
- SetText(buffer, false);
-
- if (EPGSearchConfig.checkTimerConflAfterTimerProg && !Force && timer && timerMatch && timerMatch != OldTimerMatch)
- {
- cConflictCheck C;
- C.Check();
- if (C.TimerInConflict(timer))
- gl_InfoConflict = 1;
- }
-
- return true;
- }
- return result;
+ }
+ } else {
+ t[0] = event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? 'R' : (timerActive ? 'T' : 'i')) : (timerActive ? 't' : ' ') : ' ';
+ t[1] = '\0';
+ v[0] = event && event->Vps() && (event->Vps() - event->StartTime()) ? 'V' : ' ';
+ v[1] = '\0';
+ r[0] = event && event->IsRunning() ? '*' : ' ';
+ r[1] = '\0';
+ }
+ if (event && inSwitchList) {
+ cSwitchTimer* s = SwitchTimers.InSwitchList(event);
+ t[0] = (s && s->mode == 1) ? 's' : 'S';
+ }
+ if (t[0] != 'T' && previewTimer)
+ t[0] = 'P';
+
+ strcpy(szStatus, t);
+ strcat(szStatus, v);
+ strcat(szStatus, r);
+
+ char* buffer = strdup(menuTemplate->MenuTemplate());
+ strreplace(buffer, '|', '\t');
+
+ if (!strcasestr(buffer, "%subtitle%") && cTemplFile::GetTemplateByName("MenuFavorites") != menuTemplate)
+ // make sure, there is a subtitle
+ buffer = strreplacei(buffer, "%title%", "%title% ~ %subtitle%");
+ if (episodeOnly)
+ buffer = strreplacei(buffer, "%title%", "");
+
+ // parse the epxression and evaluate it
+ cVarExpr varExpr(buffer);
+ char* tmp = strdup(varExpr.Evaluate(event).c_str());
+ free(buffer);
+ buffer = tmp;
+
+ buffer = strreplacei(buffer, "$status$", szStatus);
+ buffer = strreplacei(buffer, "$t_status$", t);
+ buffer = strreplacei(buffer, "$v_status$", v);
+ buffer = strreplacei(buffer, "$r_status$", r);
+
+ buffer = FixSeparators(buffer, '~');
+ buffer = FixSeparators(buffer, ':');
+ buffer = FixSeparators(buffer, '-');
+
+ SetText(buffer, false);
+
+ if (EPGSearchConfig.checkTimerConflAfterTimerProg && !Force && timer && timerMatch && timerMatch != OldTimerMatch) {
+ cConflictCheck C;
+ C.Check();
+ if (C.TimerInConflict(timer))
+ gl_InfoConflict = 1;
+ }
+
+ return true;
+ }
+ return result;
}
cMenuSearchResultsItem::cMenuSearchResultsItem(const cRecording *Recording)
{
- previewTimer = false;
- episodeOnly = false;
- menuTemplate = NULL;
- timerMatch = tmNone;
- inSwitchList = false;
- event = NULL;
- search = NULL;
- fileName = strdup(Recording->FileName());
- SetText(Recording->Title('\t'));
+ previewTimer = false;
+ episodeOnly = false;
+ menuTemplate = NULL;
+ timerMatch = tmNone;
+ inSwitchList = false;
+ event = NULL;
+ search = NULL;
+ fileName = strdup(Recording->FileName());
+ SetText(Recording->Title('\t'));
}
void cMenuSearchResultsItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable)
{
- LOCK_CHANNELS_READ;
- const cChannel *channel = event?Channels->GetByChannelID(event->ChannelID(), true, true):NULL;
- if (!event)
- DisplayMenu->SetItem(Text(), Index, Current, Selectable);
- else if (!DisplayMenu->SetItemEvent(event, Index, Current, Selectable, channel, true, timerMatch))
- DisplayMenu->SetItem(Text(), Index, Current, Selectable);
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = event ? Channels->GetByChannelID(event->ChannelID(), true, true) : NULL;
+ if (!event)
+ DisplayMenu->SetItem(Text(), Index, Current, Selectable);
+ else if (!DisplayMenu->SetItemEvent(event, Index, Current, Selectable, channel, true, timerMatch))
+ DisplayMenu->SetItem(Text(), Index, Current, Selectable);
}
// --- cMenuSearchResults -------------------------------------------------------
@@ -199,771 +190,732 @@ void cMenuSearchResultsItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Inde
const cEvent *cMenuSearchResults::scheduleEventInfo = NULL;
cMenuSearchResults::cMenuSearchResults(cMenuTemplate* MenuTemplate)
-:cOsdMenu("", MenuTemplate->Tab(0), MenuTemplate->Tab(1), MenuTemplate->Tab(2), MenuTemplate->Tab(3), MenuTemplate->Tab(4))
+ : cOsdMenu("", MenuTemplate->Tab(0), MenuTemplate->Tab(1), MenuTemplate->Tab(2), MenuTemplate->Tab(3), MenuTemplate->Tab(4))
{
- SetMenuCategory(mcSchedule);
+ SetMenuCategory(mcSchedule);
- helpKeys = -1;
- menuTemplate = MenuTemplate;
- modeYellow = showTitleEpisode;
- modeBlue = showAll;
- m_bSort = false;
- ignoreRunning = false;
+ helpKeys = -1;
+ menuTemplate = MenuTemplate;
+ modeYellow = showTitleEpisode;
+ modeBlue = showAll;
+ m_bSort = false;
+ ignoreRunning = false;
}
int cMenuSearchResults::GetTab(int Tab)
{
- if (!menuTemplate)
- menuTemplate = cTemplFile::GetTemplateByName("MenuSearchResults");
+ if (!menuTemplate)
+ menuTemplate = cTemplFile::GetTemplateByName("MenuSearchResults");
- return menuTemplate->Tab(Tab-1);
+ return menuTemplate->Tab(Tab - 1);
}
bool cMenuSearchResults::Update(void)
{
- bool result = false;
- LOCK_TIMERS_READ;
- for (cOsdItem *item = First(); item; item = Next(item)) {
- if (((cMenuSearchResultsItem *)item)->Update(Timers))
- result = true;
- }
- return result;
+ bool result = false;
+ LOCK_TIMERS_READ;
+ for (cOsdItem *item = First(); item; item = Next(item)) {
+ if (((cMenuSearchResultsItem *)item)->Update(Timers))
+ result = true;
+ }
+ return result;
}
eOSState cMenuSearchResults::Record(void)
{
- UpdateCurrent();
- cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
- if (item) {
- LOCK_TIMERS_WRITE;
- Timers->SetExplicitModify();
- if (item->timerMatch == tmFull)
- {
- eTimerMatch tm = tmNone;
- cTimer *timer = Timers->GetMatch(item->event, &tm);
- if (timer)
- {
- if (EPGSearchConfig.useVDRTimerEditMenu)
- return AddSubMenu(new cMenuEditTimer(timer));
- else
- return AddSubMenu(new cMenuMyEditTimer(timer, false, item->event));
- }
- }
-
- cTimer *timer = new cTimer(item->event);
- PrepareTimerFile(item->event, timer);
- cTimer *t = Timers->GetTimer(timer);
- if (EPGSearchConfig.onePressTimerCreation == 0 || t || !item->event || (!t && item->event && item->event->StartTime() - (Setup.MarginStart+2) * 60 < time(NULL)))
- {
- if (t)
- {
- delete timer;
- timer = t;
- }
- if (EPGSearchConfig.useVDRTimerEditMenu)
- return AddSubMenu(new cMenuEditTimer(timer, !t));
- else
- return AddSubMenu(new cMenuMyEditTimer(timer, !t, item->event));
- }
- else
- {
- string fullaux = "";
- string aux = "";
- if (item->event)
- {
- const cEvent* event = item->event;
- int bstart = event->StartTime() - timer->StartTime();
- int bstop = timer->StopTime() - event->EndTime();
- int checkmode = DefTimerCheckModes.GetMode(timer->Channel());
- aux = UpdateAuxValue(aux, "channel", NumToString(timer->Channel()->Number()) + " - " + CHANNELNAME(timer->Channel()));
- aux = UpdateAuxValue(aux, "update", checkmode);
- aux = UpdateAuxValue(aux, "eventid", event->EventID());
- aux = UpdateAuxValue(aux, "bstart", bstart);
- aux = UpdateAuxValue(aux, "bstop", bstop);
- fullaux = UpdateAuxValue(fullaux, "epgsearch", aux);
- }
+ UpdateCurrent();
+ cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
+ if (item) {
+ LOCK_TIMERS_WRITE;
+ Timers->SetExplicitModify();
+ if (item->timerMatch == tmFull) {
+ eTimerMatch tm = tmNone;
+ cTimer *timer = Timers->GetMatch(item->event, &tm);
+ if (timer) {
+ if (EPGSearchConfig.useVDRTimerEditMenu)
+ return AddSubMenu(new cMenuEditTimer(timer));
+ else
+ return AddSubMenu(new cMenuMyEditTimer(timer, false, item->event));
+ }
+ }
+
+ cTimer *timer = new cTimer(item->event);
+ PrepareTimerFile(item->event, timer);
+ cTimer *t = Timers->GetTimer(timer);
+ if (EPGSearchConfig.onePressTimerCreation == 0 || t || !item->event || (!t && item->event && item->event->StartTime() - (Setup.MarginStart + 2) * 60 < time(NULL))) {
+ if (t) {
+ delete timer;
+ timer = t;
+ }
+ if (EPGSearchConfig.useVDRTimerEditMenu)
+ return AddSubMenu(new cMenuEditTimer(timer, !t));
+ else
+ return AddSubMenu(new cMenuMyEditTimer(timer, !t, item->event));
+ } else {
+ string fullaux = "";
+ string aux = "";
+ if (item->event) {
+ const cEvent* event = item->event;
+ int bstart = event->StartTime() - timer->StartTime();
+ int bstop = timer->StopTime() - event->EndTime();
+ int checkmode = DefTimerCheckModes.GetMode(timer->Channel());
+ aux = UpdateAuxValue(aux, "channel", NumToString(timer->Channel()->Number()) + " - " + CHANNELNAME(timer->Channel()));
+ aux = UpdateAuxValue(aux, "update", checkmode);
+ aux = UpdateAuxValue(aux, "eventid", event->EventID());
+ aux = UpdateAuxValue(aux, "bstart", bstart);
+ aux = UpdateAuxValue(aux, "bstop", bstop);
+ fullaux = UpdateAuxValue(fullaux, "epgsearch", aux);
+ }
#ifdef USE_PINPLUGIN
- aux = "";
- aux = UpdateAuxValue(aux, "protected", timer->FskProtection() ? "yes" : "no");
- fullaux = UpdateAuxValue(fullaux, "pin-plugin", aux);
+ aux = "";
+ aux = UpdateAuxValue(aux, "protected", timer->FskProtection() ? "yes" : "no");
+ fullaux = UpdateAuxValue(fullaux, "pin-plugin", aux);
#endif
- SetAux(timer, fullaux);
- if (Setup.SVDRPPeering && *Setup.SVDRPDefaultHost)
- timer->SetRemote(Setup.SVDRPDefaultHost);
- Timers->Add(timer);
- gl_timerStatusMonitor->SetConflictCheckAdvised();
- timer->Matches();
- Timers->SetModified();
- if (!HandleRemoteTimerModifications(timer)) {
- ERROR(tr("Epgsearch: RemoteTimerModifications failed"));
- Timers->Del(timer);
- }
-
- if (HasSubMenu())
- CloseSubMenu();
- if (Update())
- Display();
- SetHelpKeys();
- }
- }
- return osContinue;
+ SetAux(timer, fullaux);
+ if (Setup.SVDRPPeering && *Setup.SVDRPDefaultHost)
+ timer->SetRemote(Setup.SVDRPDefaultHost);
+ Timers->Add(timer);
+ gl_timerStatusMonitor->SetConflictCheckAdvised();
+ timer->Matches();
+ Timers->SetModified();
+ if (!HandleRemoteTimerModifications(timer)) {
+ ERROR(tr("Epgsearch: RemoteTimerModifications failed"));
+ Timers->Del(timer);
+ }
+
+ if (HasSubMenu())
+ CloseSubMenu();
+ if (Update())
+ Display();
+ SetHelpKeys();
+ }
+ }
+ return osContinue;
}
eOSState cMenuSearchResults::Switch(void)
{
- UpdateCurrent();
- cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
- if (item) {
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(item->event->ChannelID(), true, true);
- if (channel && cDevice::PrimaryDevice()->SwitchChannel(channel, true))
- return osEnd;
- }
- INFO(trVDR("Can't switch channel!"));
- return osContinue;
+ UpdateCurrent();
+ cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
+ if (item) {
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(item->event->ChannelID(), true, true);
+ if (channel && cDevice::PrimaryDevice()->SwitchChannel(channel, true))
+ return osEnd;
+ }
+ INFO(trVDR("Can't switch channel!"));
+ return osContinue;
}
eOSState cMenuSearchResults::Commands(eKeys Key, cSearchExt* SearchExt)
{
- if (HasSubMenu() || Count() == 0)
- return osContinue;
- cMenuSearchResultsItem *mi = (cMenuSearchResultsItem *)Get(Current());
- if (mi && mi->event) {
- cMenuSearchCommands *menu;
- eOSState state = AddSubMenu(menu = new cMenuSearchCommands(tr("EPG Commands"), mi->event, true, SearchExt));
- if (Key != kNone)
- state = menu->ProcessKey(Key);
- return state;
- }
- return osContinue;
+ if (HasSubMenu() || Count() == 0)
+ return osContinue;
+ cMenuSearchResultsItem *mi = (cMenuSearchResultsItem *)Get(Current());
+ if (mi && mi->event) {
+ cMenuSearchCommands *menu;
+ eOSState state = AddSubMenu(menu = new cMenuSearchCommands(tr("EPG Commands"), mi->event, true, SearchExt));
+ if (Key != kNone)
+ state = menu->ProcessKey(Key);
+ return state;
+ }
+ return osContinue;
}
eOSState cMenuSearchResults::ShowSummary()
{
- if (Count())
- {
- const cEvent *ei = ((cMenuSearchResultsItem *)Get(Current()))->event;
- if (ei)
- {
- const cChannel *channel;
- {
- LOCK_CHANNELS_READ;
- channel = Channels->GetByChannelID(ei->ChannelID(), true, true);
- }
- if (channel)
- return AddSubMenu(new cMenuEventSearch(ei, eventObjects));
- }
- }
- return osContinue;
+ if (Count()) {
+ const cEvent *ei = ((cMenuSearchResultsItem *)Get(Current()))->event;
+ if (ei) {
+ const cChannel *channel;
+ {
+ LOCK_CHANNELS_READ;
+ channel = Channels->GetByChannelID(ei->ChannelID(), true, true);
+ }
+ if (channel)
+ return AddSubMenu(new cMenuEventSearch(ei, eventObjects));
+ }
+ }
+ return osContinue;
}
eOSState cMenuSearchResults::OnRed(cSearchExt* searchExt)
{
- eOSState state = osUnknown;
-
- if(HasSubMenu())
- return Record();
-
- if (Count())
- {
- if (EPGSearchConfig.redkeymode==toggleKeys)
- state = Record();
- else
- {
- cMenuSearchResultsItem* mi = (cMenuSearchResultsItem*)Get(Current());
- if (mi) {
- if (mi->event) {
- state = AddSubMenu(new cMenuSearchCommands(tr("EPG Commands"),mi->event, false, searchExt));
+ eOSState state = osUnknown;
+
+ if (HasSubMenu())
+ return Record();
+
+ if (Count()) {
+ if (EPGSearchConfig.redkeymode == toggleKeys)
+ state = Record();
+ else {
+ cMenuSearchResultsItem* mi = (cMenuSearchResultsItem*)Get(Current());
+ if (mi) {
+ if (mi->event) {
+ state = AddSubMenu(new cMenuSearchCommands(tr("EPG Commands"), mi->event, false, searchExt));
+ }
}
- }
- }
- }
- return state;
+ }
+ }
+ return state;
}
eOSState cMenuSearchResults::OnGreen()
{
- eOSState state = osUnknown;
- if(!HasSubMenu())
- {
- m_bSort=!m_bSort;
- BuildList();
- state = osContinue;
- }
- return state;
+ eOSState state = osUnknown;
+ if (!HasSubMenu()) {
+ m_bSort = !m_bSort;
+ BuildList();
+ state = osContinue;
+ }
+ return state;
}
eOSState cMenuSearchResults::OnYellow()
{
- eOSState state = osUnknown;
- if(!HasSubMenu())
- {
- modeYellow = (modeYellow==showTitleEpisode?showEpisode:showTitleEpisode);
- BuildList();
- state = osContinue;
- }
- return state;
+ eOSState state = osUnknown;
+ if (!HasSubMenu()) {
+ modeYellow = (modeYellow == showTitleEpisode ? showEpisode : showTitleEpisode);
+ BuildList();
+ state = osContinue;
+ }
+ return state;
}
void cMenuSearchResults::UpdateCurrent()
{
- cEventObj* cureventObj = eventObjects.GetCurrent();
- if (cureventObj && cureventObj->Event())
- for (cMenuSearchResultsItem* item = (cMenuSearchResultsItem*)First(); item; item = (cMenuSearchResultsItem*)Next(item))
- if (item->Selectable() && item->event == cureventObj->Event())
- {
- cureventObj->Select(false);
- SetCurrent(item);
- Display();
- break;
- }
+ cEventObj* cureventObj = eventObjects.GetCurrent();
+ if (cureventObj && cureventObj->Event())
+ for (cMenuSearchResultsItem* item = (cMenuSearchResultsItem*)First(); item; item = (cMenuSearchResultsItem*)Next(item))
+ if (item->Selectable() && item->event == cureventObj->Event()) {
+ cureventObj->Select(false);
+ SetCurrent(item);
+ Display();
+ break;
+ }
}
eOSState cMenuSearchResults::ProcessKey(eKeys Key)
{
- bool HadSubMenu = HasSubMenu();
- eOSState state = cOsdMenu::ProcessKey(Key);
+ bool HadSubMenu = HasSubMenu();
+ eOSState state = cOsdMenu::ProcessKey(Key);
- if (!HasSubMenu() && HadSubMenu) // navigation in summary could have changed current item, so update it
- UpdateCurrent();
+ if (!HasSubMenu() && HadSubMenu) // navigation in summary could have changed current item, so update it
+ UpdateCurrent();
- if (state == osUnknown) {
- switch (Key) {
- case k0:
- if(!HasSubMenu())
- {
- toggleKeys = 1 - toggleKeys;
- SetHelpKeys(true);
+ if (state == osUnknown) {
+ switch (Key) {
+ case k0:
+ if (!HasSubMenu()) {
+ toggleKeys = 1 - toggleKeys;
+ SetHelpKeys(true);
}
state = osContinue;
break;
- case kGreen:
+ case kGreen:
state = OnGreen();
break;
- case kYellow:
+ case kYellow:
state = OnYellow();
break;
- case kOk:
- case kInfo:
- if(HasSubMenu())
- {
- state = cOsdMenu::ProcessKey(Key);
- break;
+ case kOk:
+ case kInfo:
+ if (HasSubMenu()) {
+ state = cOsdMenu::ProcessKey(Key);
+ break;
}
if (Count())
- state = ShowSummary();
+ state = ShowSummary();
else
- state = osBack;
+ state = osBack;
break;
- default:
+ default:
break;
- }
- }
- if (!HasSubMenu())
- {
- if ((HadSubMenu || gl_TimerProgged) && Update())
- {
- if (gl_TimerProgged) // when using epgsearch's timer edit menu, update is delayed because of SVDRP
- {
- gl_TimerProgged = 0;
+ }
+ }
+ if (!HasSubMenu()) {
+ if ((HadSubMenu || gl_TimerProgged) && Update()) {
+ if (gl_TimerProgged) { // when using epgsearch's timer edit menu, update is delayed because of SVDRP
+ gl_TimerProgged = 0;
+ SetHelpKeys();
+ }
+ Display();
+ }
+ if (Key != kNone)
SetHelpKeys();
- }
- Display();
- }
- if (Key != kNone)
- SetHelpKeys();
- if (gl_InfoConflict)
- {
- gl_InfoConflict = 0;
- if (Interface->Confirm(tr("Timer conflict! Show?")))
- state = AddSubMenu(new cMenuConflictCheck());
- }
- }
- return state;
+ if (gl_InfoConflict) {
+ gl_InfoConflict = 0;
+ if (Interface->Confirm(tr("Timer conflict! Show?")))
+ state = AddSubMenu(new cMenuConflictCheck());
+ }
+ }
+ return state;
}
// --- cMenuSearchResultsForSearch -------------------------------------------------------
cMenuSearchResultsForSearch::cMenuSearchResultsForSearch(cSearchExt* SearchExt, cMenuTemplate* MenuTemplate)
- :cMenuSearchResults(MenuTemplate)
+ : cMenuSearchResults(MenuTemplate)
{
- ButtonBlue[0] = tr("Button$all channels");
- ButtonBlue[1] = tr("Button$only FTA");
- ButtonBlue[2] = tr("Button$Timer preview");
+ ButtonBlue[0] = tr("Button$all channels");
+ ButtonBlue[1] = tr("Button$only FTA");
+ ButtonBlue[2] = tr("Button$Timer preview");
- searchExt = SearchExt;
- m_bSort = true;
- if (searchExt)
- {
- modeBlue = searchExt->useChannel==3?showNoPayTV:(EPGSearchConfig.ignorePayTV?showNoPayTV:showAll);
- BuildList();
- }
+ searchExt = SearchExt;
+ m_bSort = true;
+ if (searchExt) {
+ modeBlue = searchExt->useChannel == 3 ? showNoPayTV : (EPGSearchConfig.ignorePayTV ? showNoPayTV : showAll);
+ BuildList();
+ }
}
bool cMenuSearchResultsForSearch::BuildList()
{
- bool hasResults = false;
- int current = Current();
- Clear();
- time_t now = time(NULL);
- cSearchResults* pSearchResults = searchExt->Run(modeBlue == showNoPayTV?1:0, false, 0, NULL, modeBlue != showTimerPreview);
- Clear();
- eventObjects.Clear();
-
- if (pSearchResults)
- {
- pSearchResults->SortBy(m_bSort? CompareEventTime: CompareEventChannel);
-
- for (cSearchResult* pResultObj = pSearchResults->First();
- pResultObj;
- pResultObj = pSearchResults->Next(pResultObj))
- {
- if (ignoreRunning && now > pResultObj->event->StartTime())
- continue;
- if (!(searchExt->useAsSearchTimer && searchExt->avoidRepeats && modeBlue == showTimerPreview))
- pResultObj->needsTimer = false;
- hasResults = true;
- Add(new cMenuSearchResultsItem(pResultObj->event, modeYellow == showEpisode, pResultObj->needsTimer, menuTemplate));
- eventObjects.Add(pResultObj->event);
- }
-
- delete pSearchResults;
- }
- if (Count())
- SetCurrent(Get(0));
- SetHelpKeys(true);
+ bool hasResults = false;
+ int current = Current();
+ Clear();
+ time_t now = time(NULL);
+ cSearchResults* pSearchResults = searchExt->Run(modeBlue == showNoPayTV ? 1 : 0, false, 0, NULL, modeBlue != showTimerPreview);
+ Clear();
+ eventObjects.Clear();
+
+ if (pSearchResults) {
+ pSearchResults->SortBy(m_bSort ? CompareEventTime : CompareEventChannel);
+
+ for (cSearchResult* pResultObj = pSearchResults->First();
+ pResultObj;
+ pResultObj = pSearchResults->Next(pResultObj)) {
+ if (ignoreRunning && now > pResultObj->event->StartTime())
+ continue;
+ if (!(searchExt->useAsSearchTimer && searchExt->avoidRepeats && modeBlue == showTimerPreview))
+ pResultObj->needsTimer = false;
+ hasResults = true;
+ Add(new cMenuSearchResultsItem(pResultObj->event, modeYellow == showEpisode, pResultObj->needsTimer, menuTemplate));
+ eventObjects.Add(pResultObj->event);
+ }
+
+ delete pSearchResults;
+ }
+ if (Count())
+ SetCurrent(Get(0));
+ SetHelpKeys(true);
- cString szTitle = cString::sprintf("%d %s - %s", Count(), tr("Search results"), searchExt->search);
- SetTitle(szTitle);
+ cString szTitle = cString::sprintf("%d %s - %s", Count(), tr("Search results"), searchExt->search);
+ SetTitle(szTitle);
- SetCurrent(Get(current));
- Display();
+ SetCurrent(Get(current));
+ Display();
- return hasResults;
+ return hasResults;
}
void cMenuSearchResultsForSearch::SetHelpKeys(bool Force)
{
- cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
- int NewHelpKeys = 0;
- if (item) {
- if (item->Selectable() && item->timerMatch == tmFull)
- NewHelpKeys = 2;
- else
- NewHelpKeys = 1;
- }
-
- bool hasTimer = (NewHelpKeys == 2);
- if (NewHelpKeys != helpKeys || Force)
- {
- ModeBlueSR nextModeBlue = (ModeBlueSR)(((int)modeBlue+1)%3);
- if (nextModeBlue == showTimerPreview &&
- (searchExt->useAsSearchTimer == 0 || searchExt->avoidRepeats == 0))
- nextModeBlue = (ModeBlueSR)(((int)nextModeBlue+1)%3);
-
- if (toggleKeys==0)
- SetHelp((EPGSearchConfig.redkeymode==0?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), m_bSort? tr("Button$by channel"):tr("Button$by time"), modeYellow==showTitleEpisode?tr("Button$Episode"):tr("Button$Title"), ButtonBlue[(int)nextModeBlue]);
- else
- SetHelp((EPGSearchConfig.redkeymode==1?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), m_bSort? tr("Button$by channel"):tr("Button$by time"), modeYellow==showTitleEpisode?tr("Button$Episode"):tr("Button$Title"), ButtonBlue[(int)nextModeBlue]);
- helpKeys = NewHelpKeys;
+ cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
+ int NewHelpKeys = 0;
+ if (item) {
+ if (item->Selectable() && item->timerMatch == tmFull)
+ NewHelpKeys = 2;
+ else
+ NewHelpKeys = 1;
+ }
+
+ bool hasTimer = (NewHelpKeys == 2);
+ if (NewHelpKeys != helpKeys || Force) {
+ ModeBlueSR nextModeBlue = (ModeBlueSR)(((int)modeBlue + 1) % 3);
+ if (nextModeBlue == showTimerPreview &&
+ (searchExt->useAsSearchTimer == 0 || searchExt->avoidRepeats == 0))
+ nextModeBlue = (ModeBlueSR)(((int)nextModeBlue + 1) % 3);
+
+ if (toggleKeys == 0)
+ SetHelp((EPGSearchConfig.redkeymode == 0 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), m_bSort ? tr("Button$by channel") : tr("Button$by time"), modeYellow == showTitleEpisode ? tr("Button$Episode") : tr("Button$Title"), ButtonBlue[(int)nextModeBlue]);
+ else
+ SetHelp((EPGSearchConfig.redkeymode == 1 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), m_bSort ? tr("Button$by channel") : tr("Button$by time"), modeYellow == showTitleEpisode ? tr("Button$Episode") : tr("Button$Title"), ButtonBlue[(int)nextModeBlue]);
+ helpKeys = NewHelpKeys;
}
}
eOSState cMenuSearchResultsForSearch::ProcessKey(eKeys Key)
{
- eOSState state = cMenuSearchResults::ProcessKey(Key);
+ eOSState state = cMenuSearchResults::ProcessKey(Key);
- if (state == osUnknown) {
- switch (Key) {
- case kRecord:
- case kRed:
+ if (state == osUnknown) {
+ switch (Key) {
+ case kRecord:
+ case kRed:
state = OnRed(searchExt);
break;
- case k1...k9:
- state = HasSubMenu()?osContinue:Commands(Key, searchExt);
+ case k1...k9:
+ state = HasSubMenu() ? osContinue : Commands(Key, searchExt);
break;
- case kBlue:
+ case kBlue:
if (HasSubMenu())
- state = Switch();
- else
- {
- modeBlue = (ModeBlueSR)(((int)modeBlue+1)%3);
- if (modeBlue == showTimerPreview &&
- (!searchExt || (searchExt && (searchExt->useAsSearchTimer == 0 || searchExt->avoidRepeats == 0))))
- modeBlue = (ModeBlueSR)(((int)modeBlue+1)%3);
-
- if (modeBlue == showTimerPreview)
- m_bSort = true; // show always sorted by channel
- BuildList();
-
- state = osContinue;
+ state = Switch();
+ else {
+ modeBlue = (ModeBlueSR)(((int)modeBlue + 1) % 3);
+ if (modeBlue == showTimerPreview &&
+ (!searchExt || (searchExt && (searchExt->useAsSearchTimer == 0 || searchExt->avoidRepeats == 0))))
+ modeBlue = (ModeBlueSR)(((int)modeBlue + 1) % 3);
+
+ if (modeBlue == showTimerPreview)
+ m_bSort = true; // show always sorted by channel
+ BuildList();
+
+ state = osContinue;
}
break;
- default:
+ default:
break;
- }
- }
- return state;
+ }
+ }
+ return state;
}
// --- cMenuSearchResultsForBlacklist -------------------------------------------------------
cMenuSearchResultsForBlacklist::cMenuSearchResultsForBlacklist(cBlacklist* Blacklist)
- :cMenuSearchResults(cTemplFile::GetTemplateByName("MenuSearchResults"))
+ : cMenuSearchResults(cTemplFile::GetTemplateByName("MenuSearchResults"))
{
- ButtonBlue[0] = tr("Button$all channels");
- ButtonBlue[1] = tr("Button$only FTA");
- ButtonBlue[2] = tr("Button$Timer preview");
+ ButtonBlue[0] = tr("Button$all channels");
+ ButtonBlue[1] = tr("Button$only FTA");
+ ButtonBlue[2] = tr("Button$Timer preview");
- blacklist = Blacklist;
- m_bSort = true;
- modeBlue = blacklist->useChannel==3?showNoPayTV:(EPGSearchConfig.ignorePayTV?showNoPayTV:showAll);
+ blacklist = Blacklist;
+ m_bSort = true;
+ modeBlue = blacklist->useChannel == 3 ? showNoPayTV : (EPGSearchConfig.ignorePayTV ? showNoPayTV : showAll);
- BuildList();
+ BuildList();
}
bool cMenuSearchResultsForBlacklist::BuildList()
{
- int current = Current();
- time_t now = time(NULL);
- cSearchResults* pSearchResults = blacklist->Run();
- Clear();
- eventObjects.Clear();
- if (pSearchResults)
- {
- pSearchResults->SortBy(m_bSort? CompareEventTime: CompareEventChannel);
-
- for (cSearchResult* pResultObj = pSearchResults->First();
- pResultObj;
- pResultObj = pSearchResults->Next(pResultObj))
- {
- if (ignoreRunning && now > pResultObj->event->StartTime())
- continue;
- Add(new cMenuSearchResultsItem(pResultObj->event, modeYellow == showEpisode, false));
- eventObjects.Add(pResultObj->event);
- }
-
- delete pSearchResults;
- }
- if (Count())
- SetCurrent(Get(0));
- SetHelpKeys();
- cString szTitle = cString::sprintf("%d %s - %s", Count(), tr("Blacklist results"), blacklist->search);
- SetTitle(szTitle);
+ int current = Current();
+ time_t now = time(NULL);
+ cSearchResults* pSearchResults = blacklist->Run();
+ Clear();
+ eventObjects.Clear();
+ if (pSearchResults) {
+ pSearchResults->SortBy(m_bSort ? CompareEventTime : CompareEventChannel);
+
+ for (cSearchResult* pResultObj = pSearchResults->First();
+ pResultObj;
+ pResultObj = pSearchResults->Next(pResultObj)) {
+ if (ignoreRunning && now > pResultObj->event->StartTime())
+ continue;
+ Add(new cMenuSearchResultsItem(pResultObj->event, modeYellow == showEpisode, false));
+ eventObjects.Add(pResultObj->event);
+ }
+
+ delete pSearchResults;
+ }
+ if (Count())
+ SetCurrent(Get(0));
+ SetHelpKeys();
+ cString szTitle = cString::sprintf("%d %s - %s", Count(), tr("Blacklist results"), blacklist->search);
+ SetTitle(szTitle);
- SetCurrent(Get(current));
- Display();
+ SetCurrent(Get(current));
+ Display();
- return true;
+ return true;
}
eOSState cMenuSearchResultsForBlacklist::ProcessKey(eKeys Key)
{
- eOSState state = cMenuSearchResults::ProcessKey(Key);
+ eOSState state = cMenuSearchResults::ProcessKey(Key);
- if (state == osUnknown) {
- switch (Key) {
- case k1...k9:
- state = HasSubMenu()?osContinue:Commands(Key);
+ if (state == osUnknown) {
+ switch (Key) {
+ case k1...k9:
+ state = HasSubMenu() ? osContinue : Commands(Key);
break;
- case kRecord:
- case kRed:
+ case kRecord:
+ case kRed:
state = OnRed();
break;
- case kBlue:
+ case kBlue:
if (HasSubMenu())
- state = Switch();
+ state = Switch();
else
- state = osContinue;
+ state = osContinue;
break;
- default:
+ default:
break;
- }
- }
- return state;
+ }
+ }
+ return state;
}
void cMenuSearchResultsForBlacklist::SetHelpKeys(bool Force)
{
- cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
- int NewHelpKeys = 0;
- if (item) {
- if (item->Selectable() && item->timerMatch == tmFull)
- NewHelpKeys = 2;
- else
- NewHelpKeys = 1;
- }
-
- bool hasTimer = (NewHelpKeys == 2);
- if (NewHelpKeys != helpKeys || Force)
- {
+ cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
+ int NewHelpKeys = 0;
+ if (item) {
+ if (item->Selectable() && item->timerMatch == tmFull)
+ NewHelpKeys = 2;
+ else
+ NewHelpKeys = 1;
+ }
+
+ bool hasTimer = (NewHelpKeys == 2);
+ if (NewHelpKeys != helpKeys || Force) {
- ModeBlueSR nextModeBlue = (ModeBlueSR)(((int)modeBlue+1)%3);
- if (nextModeBlue == showTimerPreview)
- nextModeBlue = (ModeBlueSR)(((int)nextModeBlue+1)%3);
+ ModeBlueSR nextModeBlue = (ModeBlueSR)(((int)modeBlue + 1) % 3);
+ if (nextModeBlue == showTimerPreview)
+ nextModeBlue = (ModeBlueSR)(((int)nextModeBlue + 1) % 3);
- if (toggleKeys==0)
- SetHelp((EPGSearchConfig.redkeymode==0?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), m_bSort? tr("Button$by channel"):tr("Button$by time"), modeYellow==showTitleEpisode?tr("Button$Episode"):tr("Button$Title"), NULL);
- else
- SetHelp((EPGSearchConfig.redkeymode==1?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), m_bSort? tr("Button$by channel"):tr("Button$by time"), modeYellow==showTitleEpisode?tr("Button$Episode"):tr("Button$Title"), NULL);
- helpKeys = NewHelpKeys;
+ if (toggleKeys == 0)
+ SetHelp((EPGSearchConfig.redkeymode == 0 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), m_bSort ? tr("Button$by channel") : tr("Button$by time"), modeYellow == showTitleEpisode ? tr("Button$Episode") : tr("Button$Title"), NULL);
+ else
+ SetHelp((EPGSearchConfig.redkeymode == 1 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), m_bSort ? tr("Button$by channel") : tr("Button$by time"), modeYellow == showTitleEpisode ? tr("Button$Episode") : tr("Button$Title"), NULL);
+ helpKeys = NewHelpKeys;
}
}
// --- cMenuSearchResultsForQuery -------------------------------------------------------
cMenuSearchResultsForQuery::cMenuSearchResultsForQuery(const char *query, bool IgnoreRunning)
- :cMenuSearchResultsForSearch(NULL, cTemplFile::GetTemplateByName("MenuSearchResults"))
-{
- modeBlue = EPGSearchConfig.ignorePayTV?showNoPayTV:showAll;
- ignoreRunning = IgnoreRunning;
- // create a dummy search
- if (query)
- {
- searchExt = new cSearchExt;
- strcpy(searchExt->search, query);
- searchExt->mode = 0; // substring
- searchExt->useTitle = 1;
- searchExt->useSubtitle = 0;
- searchExt->useDescription = 0;
- searchExt->blacklistMode = blacklistsNone;
- BuildList();
- }
+ : cMenuSearchResultsForSearch(NULL, cTemplFile::GetTemplateByName("MenuSearchResults"))
+{
+ modeBlue = EPGSearchConfig.ignorePayTV ? showNoPayTV : showAll;
+ ignoreRunning = IgnoreRunning;
+ // create a dummy search
+ if (query) {
+ searchExt = new cSearchExt;
+ strcpy(searchExt->search, query);
+ searchExt->mode = 0; // substring
+ searchExt->useTitle = 1;
+ searchExt->useSubtitle = 0;
+ searchExt->useDescription = 0;
+ searchExt->blacklistMode = blacklistsNone;
+ BuildList();
+ }
}
cMenuSearchResultsForQuery::~cMenuSearchResultsForQuery()
{
- delete searchExt;
+ delete searchExt;
}
bool cMenuSearchResultsForQuery::BuildList()
{
- bool bRes = cMenuSearchResultsForSearch::BuildList();
-/* if (!bRes)
- {
- char* szMessage = NULL;
- asprintf(&szMessage, tr("No results! Try again with tolerance %d?"), searchExt->mode == 5?searchExt->fuzzyTolerance+1:1);
- string sMessage = szMessage;
- free(szMessage);
- if (Interface->Confirm(sMessage.c_str()))
- {
- if (searchExt->mode == 5) // fuzzy
- searchExt->fuzzyTolerance++;
- searchExt->mode = 5;
- return BuildList();
- }
- }
-*/ return bRes;
+ bool bRes = cMenuSearchResultsForSearch::BuildList();
+ /* if (!bRes)
+ {
+ char* szMessage = NULL;
+ asprintf(&szMessage, tr("No results! Try again with tolerance %d?"), searchExt->mode == 5?searchExt->fuzzyTolerance+1:1);
+ string sMessage = szMessage;
+ free(szMessage);
+ if (Interface->Confirm(sMessage.c_str()))
+ {
+ if (searchExt->mode == 5) // fuzzy
+ searchExt->fuzzyTolerance++;
+ searchExt->mode = 5;
+ return BuildList();
+ }
+ }
+ */ return bRes;
}
// --- cMenuSearchResultsForRecs -------------------------------------------------------
cMenuSearchResultsForRecs::cMenuSearchResultsForRecs(const char *query)
- :cMenuSearchResultsForQuery(NULL)
-{
- SetMenuCategory(mcCommand);
- SetTitle(tr("found recordings"));
- if (query)
- {
- searchExt = new cSearchExt;
- strcpy(searchExt->search, query);
- searchExt->mode = 0; // substring
- searchExt->useTitle = 1;
- searchExt->useSubtitle = 0;
- searchExt->useDescription = 0;
- BuildList();
- }
+ : cMenuSearchResultsForQuery(NULL)
+{
+ SetMenuCategory(mcCommand);
+ SetTitle(tr("found recordings"));
+ if (query) {
+ searchExt = new cSearchExt;
+ strcpy(searchExt->search, query);
+ searchExt->mode = 0; // substring
+ searchExt->useTitle = 1;
+ searchExt->useSubtitle = 0;
+ searchExt->useDescription = 0;
+ BuildList();
+ }
}
bool cMenuSearchResultsForRecs::BuildList()
{
- const cRecording **pArray = NULL;
- int num = 0;
-
- int current = Current();
- Clear();
- {
- LOCK_RECORDINGS_READ;
- for (const cRecording *recording = Recordings->First(); recording; recording = Recordings->Next(recording)) {
- const cRecordingInfo *recInfo = recording->Info();
- if (!recInfo) continue;
- string s1 = (recInfo && recInfo->Title())?recInfo->Title():"";
- string s2 = searchExt->search;
- if (s1.empty() || s2.empty()) continue;
-
- // tolerance for fuzzy searching: 90% of the shorter text length, but at least 1
- int tolerance = std::max(1, (int)std::min(s1.size(), s2.size()) / 10);
+ const cRecording **pArray = NULL;
+ int num = 0;
- bool match = FindIgnoreCase(s1, s2) >= 0 ||
- FindIgnoreCase(s2, s1) >= 0;
-
- if (!match)
- {
- AFUZZY af = { NULL, NULL, NULL, NULL, NULL, NULL, { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 };
- if (s1.size() > 32) s1 = s1.substr(0, 32);
- afuzzy_init(s1.c_str(), tolerance, 0, &af);
- /* Checking substring */
- int res = afuzzy_checkSUB(s2.c_str(), &af);
- afuzzy_free(&af);
- match = (res > 0);
- }
- if (!match)
- {
- AFUZZY af = { NULL, NULL, NULL, NULL, NULL, NULL, { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 };
- if (s2.size() > 32) s2 = s2.substr(0, 32);
- afuzzy_init(s2.c_str(), tolerance, 0, &af);
- /* Checking substring */
- int res = afuzzy_checkSUB(s1.c_str(), &af);
- afuzzy_free(&af);
- match = (res > 0);
- }
+ int current = Current();
+ Clear();
+ {
+ LOCK_RECORDINGS_READ;
+ for (const cRecording *recording = Recordings->First(); recording; recording = Recordings->Next(recording)) {
+ const cRecordingInfo *recInfo = recording->Info();
+ if (!recInfo) continue;
+ string s1 = (recInfo && recInfo->Title()) ? recInfo->Title() : "";
+ string s2 = searchExt->search;
+ if (s1.empty() || s2.empty()) continue;
+
+ // tolerance for fuzzy searching: 90% of the shorter text length, but at least 1
+ int tolerance = std::max(1, (int)std::min(s1.size(), s2.size()) / 10);
+
+ bool match = FindIgnoreCase(s1, s2) >= 0 ||
+ FindIgnoreCase(s2, s1) >= 0;
+
+ if (!match) {
+ AFUZZY af = { NULL, NULL, NULL, NULL, NULL, NULL, { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 };
+ if (s1.size() > 32) s1 = s1.substr(0, 32);
+ afuzzy_init(s1.c_str(), tolerance, 0, &af);
+ /* Checking substring */
+ int res = afuzzy_checkSUB(s2.c_str(), &af);
+ afuzzy_free(&af);
+ match = (res > 0);
+ }
+ if (!match) {
+ AFUZZY af = { NULL, NULL, NULL, NULL, NULL, NULL, { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 };
+ if (s2.size() > 32) s2 = s2.substr(0, 32);
+ afuzzy_init(s2.c_str(), tolerance, 0, &af);
+ /* Checking substring */
+ int res = afuzzy_checkSUB(s1.c_str(), &af);
+ afuzzy_free(&af);
+ match = (res > 0);
+ }
- if (match) {
- const cRecording **tmp = (const cRecording **)realloc(pArray, (num + 1) * sizeof(cRecording *));
- if (tmp)
- {
- pArray=tmp;
- pArray[num++] = recording;
- }
- }
- }
+ if (match) {
+ const cRecording **tmp = (const cRecording **)realloc(pArray, (num + 1) * sizeof(cRecording *));
+ if (tmp) {
+ pArray = tmp;
+ pArray[num++] = recording;
+ }
+ }
+ }
- qsort(pArray, num, sizeof(cRecording *), CompareRecording);
- for (int a = 0; a < num; a++)
- Add(new cMenuSearchResultsItem(pArray[a]));
- delete pArray;
- } // Recordinglock must be released before Display() is called
+ qsort(pArray, num, sizeof(cRecording *), CompareRecording);
+ for (int a = 0; a < num; a++)
+ Add(new cMenuSearchResultsItem(pArray[a]));
+ delete pArray;
+ } // Recordinglock must be released before Display() is called
- SetHelp(NULL);
+ SetHelp(NULL);
- SetCurrent(Get(current));
- Display();
- return true;
+ SetCurrent(Get(current));
+ Display();
+ return true;
}
const cRecording *cMenuSearchResultsForRecs::GetRecording(cMenuSearchResultsItem *Item)
{
- LOCK_RECORDINGS_READ;
- const cRecording *recording = Recordings->GetByName(Item->FileName());
- if (!recording)
- ERROR(tr("Error while accessing recording!"));
- return recording;
+ LOCK_RECORDINGS_READ;
+ const cRecording *recording = Recordings->GetByName(Item->FileName());
+ if (!recording)
+ ERROR(tr("Error while accessing recording!"));
+ return recording;
}
eOSState cMenuSearchResultsForRecs::Play(void)
{
- cMenuSearchResultsItem *ri = (cMenuSearchResultsItem*)Get(Current());
- if (ri)
- {
- const cRecording *recording = GetRecording(ri);
- if (recording) {
- cReplayControl::SetRecording(recording->FileName());
- return osReplay;
- }
- }
- return osContinue;
+ cMenuSearchResultsItem *ri = (cMenuSearchResultsItem*)Get(Current());
+ if (ri) {
+ const cRecording *recording = GetRecording(ri);
+ if (recording) {
+ cReplayControl::SetRecording(recording->FileName());
+ return osReplay;
+ }
+ }
+ return osContinue;
}
eOSState cMenuSearchResultsForRecs::ProcessKey(eKeys Key)
{
- eOSState state = cOsdMenu::ProcessKey(Key);
+ eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown)
- {
- if (Key == kOk)
- {
- if (Count() > 0)
- state = Play();
- else
- state = osBack;
- }
- else
- state = osContinue;
- }
- return state;
+ if (state == osUnknown) {
+ if (Key == kOk) {
+ if (Count() > 0)
+ state = Play();
+ else
+ state = osBack;
+ } else
+ state = osContinue;
+ }
+ return state;
}
// --- cMenuSearchResultsForList -------------------------------------------------------
cMenuSearchResultsForList::cMenuSearchResultsForList(cSearchResults& SearchResults, const char* Title, bool IgnoreRunning)
- :cMenuSearchResults(cTemplFile::GetTemplateByName("MenuSearchResults"))
+ : cMenuSearchResults(cTemplFile::GetTemplateByName("MenuSearchResults"))
{
- ButtonBlue[0] = tr("Button$Setup");
- searchResults = &SearchResults;
- m_bSort = true;
- ignoreRunning = IgnoreRunning;
+ ButtonBlue[0] = tr("Button$Setup");
+ searchResults = &SearchResults;
+ m_bSort = true;
+ ignoreRunning = IgnoreRunning;
- BuildList();
+ BuildList();
- cString szTitle = cString::sprintf(Title, Count());
- SetTitle(szTitle);
+ cString szTitle = cString::sprintf(Title, Count());
+ SetTitle(szTitle);
}
void cMenuSearchResultsForList::SetHelpKeys(bool Force)
{
- cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
- int NewHelpKeys = 0;
- if (item) {
- if (item->Selectable() && item->timerMatch == tmFull)
- NewHelpKeys = 2;
- else
- NewHelpKeys = 1;
- }
-
- bool hasTimer = (NewHelpKeys == 2);
- if (NewHelpKeys != helpKeys || Force)
- {
- if (toggleKeys==0)
- SetHelp((EPGSearchConfig.redkeymode==0?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), m_bSort? tr("Button$by channel"):tr("Button$by time"), modeYellow==showTitleEpisode?tr("Button$Episode"):tr("Button$Title"), ButtonBlue[0]);
- else
- SetHelp((EPGSearchConfig.redkeymode==1?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")), m_bSort? tr("Button$by channel"):tr("Button$by time"), modeYellow==showTitleEpisode?tr("Button$Episode"):tr("Button$Title"), ButtonBlue[0]);
- helpKeys = NewHelpKeys;
+ cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
+ int NewHelpKeys = 0;
+ if (item) {
+ if (item->Selectable() && item->timerMatch == tmFull)
+ NewHelpKeys = 2;
+ else
+ NewHelpKeys = 1;
+ }
+
+ bool hasTimer = (NewHelpKeys == 2);
+ if (NewHelpKeys != helpKeys || Force) {
+ if (toggleKeys == 0)
+ SetHelp((EPGSearchConfig.redkeymode == 0 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), m_bSort ? tr("Button$by channel") : tr("Button$by time"), modeYellow == showTitleEpisode ? tr("Button$Episode") : tr("Button$Title"), ButtonBlue[0]);
+ else
+ SetHelp((EPGSearchConfig.redkeymode == 1 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")), m_bSort ? tr("Button$by channel") : tr("Button$by time"), modeYellow == showTitleEpisode ? tr("Button$Episode") : tr("Button$Title"), ButtonBlue[0]);
+ helpKeys = NewHelpKeys;
}
}
bool cMenuSearchResultsForList::BuildList()
{
- time_t now = time(NULL);
- int current = Current();
+ time_t now = time(NULL);
+ int current = Current();
- Clear();
- eventObjects.Clear();
- searchResults->SortBy(m_bSort? CompareEventTime: CompareEventChannel);
+ Clear();
+ eventObjects.Clear();
+ searchResults->SortBy(m_bSort ? CompareEventTime : CompareEventChannel);
- for (cSearchResult* pResultObj = searchResults->First();
- pResultObj;
- pResultObj = searchResults->Next(pResultObj))
- {
- if (ignoreRunning && now > pResultObj->event->StartTime())
- continue;
- Add(new cMenuSearchResultsItem(pResultObj->event, modeYellow == showEpisode, false, menuTemplate, pResultObj->search));
- eventObjects.Add(pResultObj->event);
- }
- if (Count())
- SetCurrent(Get(0));
+ for (cSearchResult* pResultObj = searchResults->First();
+ pResultObj;
+ pResultObj = searchResults->Next(pResultObj)) {
+ if (ignoreRunning && now > pResultObj->event->StartTime())
+ continue;
+ Add(new cMenuSearchResultsItem(pResultObj->event, modeYellow == showEpisode, false, menuTemplate, pResultObj->search));
+ eventObjects.Add(pResultObj->event);
+ }
+ if (Count())
+ SetCurrent(Get(0));
- SetHelpKeys();
+ SetHelpKeys();
- SetCurrent(Get(current));
- Display();
+ SetCurrent(Get(current));
+ Display();
- return true;
+ return true;
}
eOSState cMenuSearchResultsForList::ProcessKey(eKeys Key)
{
- eOSState state = cMenuSearchResults::ProcessKey(Key);
+ eOSState state = cMenuSearchResults::ProcessKey(Key);
- if (state == osUnknown) {
- switch (Key) {
- case k1...k9:
- state = HasSubMenu()?osContinue:Commands(Key);
+ if (state == osUnknown) {
+ switch (Key) {
+ case k1...k9:
+ state = HasSubMenu() ? osContinue : Commands(Key);
break;
- case kRecord:
- case kRed:
+ case kRecord:
+ case kRed:
state = OnRed();
break;
- default:
+ default:
break;
- }
- }
- return state;
+ }
+ }
+ return state;
}
diff --git a/menu_searchresults.h b/menu_searchresults.h
index 6bb7f62..cc88fd1 100644
--- a/menu_searchresults.h
+++ b/menu_searchresults.h
@@ -30,32 +30,33 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "epgsearchext.h"
#include "menu_event.h"
-typedef enum
-{
+typedef enum {
showTitleEpisode,
showEpisode
} ModeYellowSR;
-typedef enum
-{
+typedef enum {
showAll,
showNoPayTV,
showTimerPreview
} ModeBlueSR;
// --- cMenuSearchResultsItem ------------------------------------------------------
-class cMenuSearchResultsItem : public cOsdItem {
+class cMenuSearchResultsItem : public cOsdItem
+{
char *fileName; // for search in recordings
bool previewTimer;
bool episodeOnly;
cMenuTemplate* menuTemplate;
- public:
+public:
eTimerMatch timerMatch;
bool inSwitchList;
bool timerActive;
const cEvent *event;
const cSearchExt* search;
- const char *FileName(void) { return fileName; }
+ const char *FileName(void) {
+ return fileName;
+ }
cMenuSearchResultsItem(const cEvent *EventInfo, bool EpisodeOnly = false,
bool PreviewTimer = false, cMenuTemplate* MenuTemplate = NULL,
const cSearchExt* Search = NULL);
@@ -65,15 +66,16 @@ class cMenuSearchResultsItem : public cOsdItem {
};
// --- cMenuSearchResults ------------------------------------------------------
-class cMenuSearchResults : public cOsdMenu {
+class cMenuSearchResults : public cOsdMenu
+{
friend class cMenuFavorites;
- protected:
+protected:
int helpKeys;
cMenuTemplate* menuTemplate;
bool ignoreRunning;
cEventObjects eventObjects;
- virtual bool BuildList()=0;
+ virtual bool BuildList() = 0;
virtual eOSState ProcessKey(eKeys Key);
eOSState ShowSummary(void);
virtual eOSState OnRed(cSearchExt* searchExt = NULL);
@@ -83,68 +85,73 @@ class cMenuSearchResults : public cOsdMenu {
eOSState Switch(void);
eOSState Commands(eKeys Key, cSearchExt* SearchExt = NULL);
int GetTab(int Tab);
- virtual void SetHelpKeys(bool Force=false)=0;
+ virtual void SetHelpKeys(bool Force = false) = 0;
bool Update(void);
void UpdateCurrent();
static const cEvent *scheduleEventInfo;
ModeYellowSR modeYellow;
ModeBlueSR modeBlue;
- public:
+public:
bool m_bSort;
cMenuSearchResults(cMenuTemplate* MenuTemplate);
};
// --- cMenuSearchResultsForSearch ------------------------------------------------------
-class cMenuSearchResultsForSearch : public cMenuSearchResults {
- protected:
+class cMenuSearchResultsForSearch : public cMenuSearchResults
+{
+protected:
cSearchExt* searchExt;
virtual bool BuildList();
- virtual void SetHelpKeys(bool Force=false);
+ virtual void SetHelpKeys(bool Force = false);
eOSState ProcessKey(eKeys Key);
- public:
+public:
cMenuSearchResultsForSearch(cSearchExt*, cMenuTemplate* MenuTemplate);
virtual ~cMenuSearchResultsForSearch() {}
};
class cBlacklist;
// --- cMenuSearchResultsForBlacklist ------------------------------------------------------
-class cMenuSearchResultsForBlacklist : public cMenuSearchResults {
+class cMenuSearchResultsForBlacklist : public cMenuSearchResults
+{
cBlacklist* blacklist;
virtual bool BuildList();
- virtual void SetHelpKeys(bool Force=false);
+ virtual void SetHelpKeys(bool Force = false);
eOSState ProcessKey(eKeys Key);
- public:
+public:
cMenuSearchResultsForBlacklist(cBlacklist*);
};
// --- cMenuSearchResultsForQuery ------------------------------------------------------
-class cMenuSearchResultsForQuery : public cMenuSearchResultsForSearch {
- public:
- cMenuSearchResultsForQuery(const char *query, bool IgnoreRunning = false);
- ~cMenuSearchResultsForQuery();
- virtual bool BuildList();
+class cMenuSearchResultsForQuery : public cMenuSearchResultsForSearch
+{
+public:
+ cMenuSearchResultsForQuery(const char *query, bool IgnoreRunning = false);
+ ~cMenuSearchResultsForQuery();
+ virtual bool BuildList();
};
// --- cMenuSearchResultsForRecs ------------------------------------------------------
-class cMenuSearchResultsForRecs : public cMenuSearchResultsForQuery {
+class cMenuSearchResultsForRecs : public cMenuSearchResultsForQuery
+{
virtual bool BuildList();
eOSState ProcessKey(eKeys Key);
eOSState Play(void);
const cRecording *GetRecording(cMenuSearchResultsItem *Item);
- public:
- cMenuSearchResultsForRecs(const char *query);
+public:
+ cMenuSearchResultsForRecs(const char *query);
};
// --- cMenuSearchResultsForList ------------------------------------------------------
-class cMenuSearchResultsForList : public cMenuSearchResults {
- protected:
+class cMenuSearchResultsForList : public cMenuSearchResults
+{
+protected:
cSearchResults* searchResults;
virtual bool BuildList();
- virtual void SetHelpKeys(bool Force=false);
+ virtual void SetHelpKeys(bool Force = false);
virtual eOSState ProcessKey(eKeys Key);
- public:
+public:
cMenuSearchResultsForList(cSearchResults& SearchResults, const char* Title, bool IgnoreRunning = false);
};
diff --git a/menu_searchtemplate.c b/menu_searchtemplate.c
index a38484c..3a837b6 100644
--- a/menu_searchtemplate.c
+++ b/menu_searchtemplate.c
@@ -36,14 +36,15 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
using namespace std;
// --- cMenuSearchTemplateItem ----------------------------------------------------------
-class cMenuSearchTemplateItem : public cOsdItem {
- private:
+class cMenuSearchTemplateItem : public cOsdItem
+{
+private:
public:
- cSearchExt* searchExt;
- cMenuSearchTemplateItem(cSearchExt* SearchExt);
- int Compare(const cListObject &ListObject) const;
- void Set(void);
- };
+ cSearchExt* searchExt;
+ cMenuSearchTemplateItem(cSearchExt* SearchExt);
+ int Compare(const cListObject &ListObject) const;
+ void Set(void);
+};
cMenuSearchTemplateItem::cMenuSearchTemplateItem(cSearchExt* SearchExt)
{
@@ -53,69 +54,64 @@ cMenuSearchTemplateItem::cMenuSearchTemplateItem(cSearchExt* SearchExt)
void cMenuSearchTemplateItem::Set(void)
{
- ostringstream line;
-
- if (searchExt->ID == EPGSearchConfig.DefSearchTemplateID)
- line << "*";
- else if (searchExt->useAsSearchTimer)
- {
- if (searchExt->IsActiveAt(time(NULL)))
- line << ">";
- else
- line << "!";
+ ostringstream line;
+
+ if (searchExt->ID == EPGSearchConfig.DefSearchTemplateID)
+ line << "*";
+ else if (searchExt->useAsSearchTimer) {
+ if (searchExt->IsActiveAt(time(NULL)))
+ line << ">";
+ else
+ line << "!";
}
- line << "\t";
- if (searchExt->search && strlen(searchExt->search) > 0)
- line << setiosflags(ios::left) << string(searchExt->search);
- else
- line << setiosflags(ios::left) << "*";
-
- line << "\t";
- if (searchExt->useChannel == 1)
- {
- if (searchExt->channelMin != searchExt->channelMax)
- line << setiosflags(ios::left) << searchExt->channelMin->Number() << " - " << searchExt->channelMax->Number();
- else
- line << setiosflags(ios::left) << setw(11) << (searchExt->useChannel?CHANNELNAME(searchExt->channelMin):"");
- }
- else if (searchExt->useChannel == 2)
- line << setiosflags(ios::left) << setw(11) << searchExt->channelGroup;
-
- line << "\t";
- if (searchExt->useTime)
- {
- ostringstream timeline;
- timeline << setfill('0') << setw(2) << searchExt->startTime / 100 << ":" << setw(2) << searchExt->startTime % 100;
- timeline << "\t";
- timeline << setfill('0') << setw(2) << searchExt->stopTime / 100 << ":" << setw(2) << searchExt->stopTime % 100;
- line << timeline.str();
- }
- else
- line << "--:--\t--:--";
-
- SetText(strdup(line.str().c_str()), false);
+ line << "\t";
+ if (searchExt->search && strlen(searchExt->search) > 0)
+ line << setiosflags(ios::left) << string(searchExt->search);
+ else
+ line << setiosflags(ios::left) << "*";
+
+ line << "\t";
+ if (searchExt->useChannel == 1) {
+ if (searchExt->channelMin != searchExt->channelMax)
+ line << setiosflags(ios::left) << searchExt->channelMin->Number() << " - " << searchExt->channelMax->Number();
+ else
+ line << setiosflags(ios::left) << setw(11) << (searchExt->useChannel ? CHANNELNAME(searchExt->channelMin) : "");
+ } else if (searchExt->useChannel == 2)
+ line << setiosflags(ios::left) << setw(11) << searchExt->channelGroup;
+
+ line << "\t";
+ if (searchExt->useTime) {
+ ostringstream timeline;
+ timeline << setfill('0') << setw(2) << searchExt->startTime / 100 << ":" << setw(2) << searchExt->startTime % 100;
+ timeline << "\t";
+ timeline << setfill('0') << setw(2) << searchExt->stopTime / 100 << ":" << setw(2) << searchExt->stopTime % 100;
+ line << timeline.str();
+ } else
+ line << "--:--\t--:--";
+
+ SetText(strdup(line.str().c_str()), false);
}
int cMenuSearchTemplateItem::Compare(const cListObject &ListObject) const
{
- cMenuSearchTemplateItem *p = (cMenuSearchTemplateItem *)&ListObject;
- return strcasecmp(searchExt->search, p->searchExt->search);
+ cMenuSearchTemplateItem *p = (cMenuSearchTemplateItem *)&ListObject;
+ return strcasecmp(searchExt->search, p->searchExt->search);
}
// --- cMenuEPGSearchTemplate ----------------------------------------------------------
cMenuEPGSearchTemplate::cMenuEPGSearchTemplate(cSearchExt* Search, cBlacklist* Blacklist, bool New)
-:cOsdMenu(tr("Search templates"), 2, 20, 11, 6, 5)
+ : cOsdMenu(tr("Search templates"), 2, 20, 11, 6, 5)
{
- SetMenuCategory(mcPlugin);
+ SetMenuCategory(mcPlugin);
search = Search;
blacklist = Blacklist;
newSearch = New;
cMutexLock SearchTemplatesLock(&SearchTemplates);
cSearchExt *SearchExt = SearchTemplates.First();
while (SearchExt) {
- Add(new cMenuSearchTemplateItem(SearchExt));
- SearchExt = SearchTemplates.Next(SearchExt);
+ Add(new cMenuSearchTemplateItem(SearchExt));
+ SearchExt = SearchTemplates.Next(SearchExt);
}
SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), tr("Button$Default"));
Sort();
@@ -131,127 +127,126 @@ cSearchExt *cMenuEPGSearchTemplate::CurrentSearchTemplate(void)
eOSState cMenuEPGSearchTemplate::New(void)
{
- if (HasSubMenu())
- return osContinue;
- return AddSubMenu(new cMenuEditTemplate(new cSearchExt, true));
+ if (HasSubMenu())
+ return osContinue;
+ return AddSubMenu(new cMenuEditTemplate(new cSearchExt, true));
}
eOSState cMenuEPGSearchTemplate::Delete(void)
{
cSearchExt *curSearchExt = CurrentSearchTemplate();
if (curSearchExt) {
- if (Interface->Confirm(tr("Edit$Delete template?"))) {
- cMutexLock SearchTemplatesLock(&SearchTemplates);
- SearchTemplates.Del(curSearchExt);
- SearchTemplates.Save();
- cOsdMenu::Del(Current());
- Display();
- }
+ if (Interface->Confirm(tr("Edit$Delete template?"))) {
+ cMutexLock SearchTemplatesLock(&SearchTemplates);
+ SearchTemplates.Del(curSearchExt);
+ SearchTemplates.Save();
+ cOsdMenu::Del(Current());
+ Display();
+ }
}
return osContinue;
}
eOSState cMenuEPGSearchTemplate::DefaultTemplate(void)
{
- if (HasSubMenu())
- return osContinue;
- cSearchExt *curSearchExt = CurrentSearchTemplate();
+ if (HasSubMenu())
+ return osContinue;
+ cSearchExt *curSearchExt = CurrentSearchTemplate();
- int current = Current();
- cMenuSearchTemplateItem *oldDefaultTemplateItem = NULL;
- for(int i=0; i<Count(); i++)
- {
- cMenuSearchTemplateItem *item = (cMenuSearchTemplateItem *)Get(i);
- if (item && item->searchExt && item->searchExt->ID == EPGSearchConfig.DefSearchTemplateID)
- oldDefaultTemplateItem = item;
- }
+ int current = Current();
+ cMenuSearchTemplateItem *oldDefaultTemplateItem = NULL;
+ for (int i = 0; i < Count(); i++) {
+ cMenuSearchTemplateItem *item = (cMenuSearchTemplateItem *)Get(i);
+ if (item && item->searchExt && item->searchExt->ID == EPGSearchConfig.DefSearchTemplateID)
+ oldDefaultTemplateItem = item;
+ }
- if (curSearchExt)
- {
- if (EPGSearchConfig.DefSearchTemplateID == curSearchExt->ID)
- EPGSearchConfig.DefSearchTemplateID = -1;
- else
- EPGSearchConfig.DefSearchTemplateID = curSearchExt->ID;
- cPluginManager::GetPlugin("epgsearch")->SetupStore("DefSearchTemplateID", EPGSearchConfig.DefSearchTemplateID);
+ if (curSearchExt) {
+ if (EPGSearchConfig.DefSearchTemplateID == curSearchExt->ID)
+ EPGSearchConfig.DefSearchTemplateID = -1;
+ else
+ EPGSearchConfig.DefSearchTemplateID = curSearchExt->ID;
+ cPluginManager::GetPlugin("epgsearch")->SetupStore("DefSearchTemplateID", EPGSearchConfig.DefSearchTemplateID);
- SetCurrent(oldDefaultTemplateItem);
- RefreshCurrent();
- DisplayCurrent(true);
+ SetCurrent(oldDefaultTemplateItem);
+ RefreshCurrent();
+ DisplayCurrent(true);
- SetCurrent(Get(current));
- RefreshCurrent();
- DisplayCurrent(true);
+ SetCurrent(Get(current));
+ RefreshCurrent();
+ DisplayCurrent(true);
- Display();
- }
- return osContinue;
+ Display();
+ }
+ return osContinue;
}
eOSState cMenuEPGSearchTemplate::ProcessKey(eKeys Key)
{
- int SearchNumber = HasSubMenu() ? Count() : -1;
- eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown) {
- if (HasSubMenu())
- return osContinue;
- switch (Key) {
- case kOk:
- {
- if (search)
- {
- if (!newSearch && !Interface->Confirm(tr("Overwrite existing entries?")))
- return osBack;
- // duplicate template
- cSearchExt* t =CurrentSearchTemplate();
- if (!t) return osContinue;
- // copy all except the name and id
- search->CopyFromTemplate(t);
- }
- if (blacklist)
- {
- if (!newSearch && !Interface->Confirm(tr("Overwrite existing entries?")))
- return osBack;
- // duplicate template
- cSearchExt* t =CurrentSearchTemplate();
- if (!t) return osContinue;
- // copy all except the name and id
- blacklist->CopyFromTemplate(t);
- }
- return osBack;
- }
- case kRed:
- if (CurrentSearchTemplate())
- state = AddSubMenu(new cMenuEditTemplate(CurrentSearchTemplate()));
- else
- state = osContinue;
- break;
- case kGreen: state = New(); break;
- case kYellow: state = Delete(); break;
- case kBlue: state = DefaultTemplate(); break;
- default: break;
- }
- }
- if (SearchNumber >= 0 && !HasSubMenu())
- {
- cSearchExt* search = SearchTemplates.Get(SearchNumber);
- if (search) // a newly created template was confirmed with Ok
- Add(new cMenuSearchTemplateItem(search));
- else
- search = CurrentSearchTemplate();
- // always update all entries, since channel group names may have changed and affect other searches
- Sort();
- for(int i=0; i<Count(); i++)
- {
- cMenuSearchTemplateItem *item = (cMenuSearchTemplateItem *)Get(i);
- if (item)
- {
- item->Set();
- if (item->searchExt == search)
- SetCurrent(item);
- }
- }
- Display();
- }
+ int SearchNumber = HasSubMenu() ? Count() : -1;
+ eOSState state = cOsdMenu::ProcessKey(Key);
+ if (state == osUnknown) {
+ if (HasSubMenu())
+ return osContinue;
+ switch (Key) {
+ case kOk: {
+ if (search) {
+ if (!newSearch && !Interface->Confirm(tr("Overwrite existing entries?")))
+ return osBack;
+ // duplicate template
+ cSearchExt* t = CurrentSearchTemplate();
+ if (!t) return osContinue;
+ // copy all except the name and id
+ search->CopyFromTemplate(t);
+ }
+ if (blacklist) {
+ if (!newSearch && !Interface->Confirm(tr("Overwrite existing entries?")))
+ return osBack;
+ // duplicate template
+ cSearchExt* t = CurrentSearchTemplate();
+ if (!t) return osContinue;
+ // copy all except the name and id
+ blacklist->CopyFromTemplate(t);
+ }
+ return osBack;
+ }
+ case kRed:
+ if (CurrentSearchTemplate())
+ state = AddSubMenu(new cMenuEditTemplate(CurrentSearchTemplate()));
+ else
+ state = osContinue;
+ break;
+ case kGreen:
+ state = New();
+ break;
+ case kYellow:
+ state = Delete();
+ break;
+ case kBlue:
+ state = DefaultTemplate();
+ break;
+ default:
+ break;
+ }
+ }
+ if (SearchNumber >= 0 && !HasSubMenu()) {
+ cSearchExt* search = SearchTemplates.Get(SearchNumber);
+ if (search) // a newly created template was confirmed with Ok
+ Add(new cMenuSearchTemplateItem(search));
+ else
+ search = CurrentSearchTemplate();
+ // always update all entries, since channel group names may have changed and affect other searches
+ Sort();
+ for (int i = 0; i < Count(); i++) {
+ cMenuSearchTemplateItem *item = (cMenuSearchTemplateItem *)Get(i);
+ if (item) {
+ item->Set();
+ if (item->searchExt == search)
+ SetCurrent(item);
+ }
+ }
+ Display();
+ }
- return state;
+ return state;
}
diff --git a/menu_searchtemplate.h b/menu_searchtemplate.h
index 9f37487..2d3e881 100644
--- a/menu_searchtemplate.h
+++ b/menu_searchtemplate.h
@@ -28,17 +28,18 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "epgsearchext.h"
#include "blacklist.h"
-class cMenuEPGSearchTemplate : public cOsdMenu {
- private:
+class cMenuEPGSearchTemplate : public cOsdMenu
+{
+private:
bool newSearch;
eOSState New(void);
eOSState Delete(void);
eOSState DefaultTemplate(void);
cSearchExt* search;
cBlacklist* blacklist;
- protected:
+protected:
virtual eOSState ProcessKey(eKeys Key);
- public:
+public:
cMenuEPGSearchTemplate(cSearchExt* Search, cBlacklist* Blacklist, bool New);
cSearchExt* CurrentSearchTemplate(void);
};
diff --git a/menu_switchtimers.c b/menu_switchtimers.c
index 00ccfba..0e2c65b 100644
--- a/menu_switchtimers.c
+++ b/menu_switchtimers.c
@@ -25,33 +25,33 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "epgsearchtools.h"
// --- cMenuEditSwitchTimer --------------------------------------------------------
-class cMenuEditSwitchTimer : public cOsdMenu {
+class cMenuEditSwitchTimer : public cOsdMenu
+{
private:
- char *SwitchModes[3];
- cSwitchTimer *switchTimer;
- cSwitchTimer data;
- bool addIfConfirmed;
+ char *SwitchModes[3];
+ cSwitchTimer *switchTimer;
+ cSwitchTimer data;
+ bool addIfConfirmed;
public:
- cMenuEditSwitchTimer(cSwitchTimer *SwitchTimer, bool New = false);
- void Set();
- virtual eOSState ProcessKey(eKeys Key);
+ cMenuEditSwitchTimer(cSwitchTimer *SwitchTimer, bool New = false);
+ void Set();
+ virtual eOSState ProcessKey(eKeys Key);
};
cMenuEditSwitchTimer::cMenuEditSwitchTimer(cSwitchTimer* SwitchTimer, bool New)
-:cOsdMenu(tr("Edit entry"),30)
+ : cOsdMenu(tr("Edit entry"), 30)
{
- SetMenuCategory(mcPlugin);
-
- SwitchModes[0] = strdup(tr("Switch"));
- SwitchModes[1] = strdup(tr("Announce only"));
- SwitchModes[2] = strdup(tr("Announce and switch"));
-
- switchTimer = SwitchTimer;
- addIfConfirmed = New;
- if (switchTimer)
- {
- data = *switchTimer;
- Set();
+ SetMenuCategory(mcPlugin);
+
+ SwitchModes[0] = strdup(tr("Switch"));
+ SwitchModes[1] = strdup(tr("Announce only"));
+ SwitchModes[2] = strdup(tr("Announce and switch"));
+
+ switchTimer = SwitchTimer;
+ addIfConfirmed = New;
+ if (switchTimer) {
+ data = *switchTimer;
+ Set();
}
}
@@ -62,14 +62,14 @@ void cMenuEditSwitchTimer::Set()
Add(new cMenuEditStraItem(tr("Action"), &data.mode, 3, SwitchModes));
if (data.mode == 0) // always switch
- Add(new cMenuEditIntItem(tr("Switch ... minutes before start"), &data.switchMinsBefore, 0, 99));
+ Add(new cMenuEditIntItem(tr("Switch ... minutes before start"), &data.switchMinsBefore, 0, 99));
if (data.mode == 1) // only announce
- Add(new cMenuEditIntItem(tr("Announce ... minutes before start"), &data.switchMinsBefore, 0, 99));
+ Add(new cMenuEditIntItem(tr("Announce ... minutes before start"), &data.switchMinsBefore, 0, 99));
if (data.mode == 2) // ask for switching
- Add(new cMenuEditIntItem(tr("Ask ... minutes before start"), &data.switchMinsBefore, 0, 99));
+ Add(new cMenuEditIntItem(tr("Ask ... minutes before start"), &data.switchMinsBefore, 0, 99));
cString info = cString::sprintf("%s:\t%s", tr("action at"),
- TIMESTRING(data.startTime - 60 * data.switchMinsBefore));
+ TIMESTRING(data.startTime - 60 * data.switchMinsBefore));
cOsdItem* pInfoItem = new cOsdItem(info);
pInfoItem->SetSelectable(false);
Add(pInfoItem);
@@ -84,47 +84,45 @@ eOSState cMenuEditSwitchTimer::ProcessKey(eKeys Key)
eOSState state = cOsdMenu::ProcessKey(Key);
if (iOldMinsBefore != data.switchMinsBefore ||
- iOldMode != data.mode)
- {
- time_t now = time(NULL);
- if (data.startTime - 60 * data.switchMinsBefore < now)
- data.switchMinsBefore = iOldMinsBefore;
- Set();
- Display();
+ iOldMode != data.mode) {
+ time_t now = time(NULL);
+ if (data.startTime - 60 * data.switchMinsBefore < now)
+ data.switchMinsBefore = iOldMinsBefore;
+ Set();
+ Display();
}
if (state == osUnknown) {
- switch (Key) {
- case kOk:
- {
- if (switchTimer)
- {
- *switchTimer = data;
- cMutexLock SwitchTimersLock(&SwitchTimers);
- if (addIfConfirmed)
- SwitchTimers.Add(switchTimer);
- SwitchTimers.Save();
- }
- addIfConfirmed = false;
- return osBack;
- }
- default: break;
- }
- }
+ switch (Key) {
+ case kOk: {
+ if (switchTimer) {
+ *switchTimer = data;
+ cMutexLock SwitchTimersLock(&SwitchTimers);
+ if (addIfConfirmed)
+ SwitchTimers.Add(switchTimer);
+ SwitchTimers.Save();
+ }
+ addIfConfirmed = false;
+ return osBack;
+ }
+ default:
+ break;
+ }
+ }
return state;
}
cMenuSwitchTimerItem::cMenuSwitchTimerItem(cSwitchTimer* SwitchTimer, const cEvent* Event)
{
- switchTimer = SwitchTimer;
- event = Event;
- Set();
+ switchTimer = SwitchTimer;
+ event = Event;
+ Set();
}
void cMenuSwitchTimerItem::Set()
{
if (!SwitchTimers.Exists(switchTimer) || !switchTimer || !event)
- return;
+ return;
time_t startTime = switchTimer->startTime;
char *buffer = NULL;
@@ -135,9 +133,9 @@ void cMenuSwitchTimerItem::Set()
strftime(datebuf, sizeof(datebuf), "%d.%m", tm);
LOCK_CHANNELS_READ;
- const cChannel* channel = Channels->GetByChannelID(switchTimer->channelID,true,true);
+ const cChannel* channel = Channels->GetByChannelID(switchTimer->channelID, true, true);
- msprintf(&buffer, "%s\t%d\t%s\t%s\t%d\'\t%s~%s", switchTimer->mode==1?"":">", channel?channel->Number():-1, datebuf, TIMESTRING(startTime), switchTimer->switchMinsBefore, event->Title()?event->Title():"", event->ShortText()?event->ShortText():"");
+ msprintf(&buffer, "%s\t%d\t%s\t%s\t%d\'\t%s~%s", switchTimer->mode == 1 ? "" : ">", channel ? channel->Number() : -1, datebuf, TIMESTRING(startTime), switchTimer->switchMinsBefore, event->Title() ? event->Title() : "", event->ShortText() ? event->ShortText() : "");
SetText(buffer, false);
}
@@ -145,16 +143,16 @@ int cMenuSwitchTimerItem::Compare(const cListObject &ListObject) const
{
cMenuSwitchTimerItem *p = (cMenuSwitchTimerItem *)&ListObject;
if (switchTimer->startTime > p->switchTimer->startTime)
- return 1;
+ return 1;
else
- return -1;
+ return -1;
}
// --- cMenuSwitchTimers ----------------------------------------------------------
cMenuSwitchTimers::cMenuSwitchTimers()
-:cOsdMenu(tr("Switch list"), 2, 4, 6, 6, 4)
+ : cOsdMenu(tr("Switch list"), 2, 4, 6, 6, 4)
{
- SetMenuCategory(mcPlugin);
+ SetMenuCategory(mcPlugin);
Set();
Display();
@@ -165,12 +163,11 @@ void cMenuSwitchTimers::Set()
Clear();
cMutexLock SwitchTimersLock(&SwitchTimers);
cSwitchTimer* switchTimer = SwitchTimers.First();
- while (switchTimer)
- {
- const cEvent* event = switchTimer->Event();
- if (event)
- Add(new cMenuSwitchTimerItem(switchTimer, event));
- switchTimer = SwitchTimers.Next(switchTimer);
+ while (switchTimer) {
+ const cEvent* event = switchTimer->Event();
+ if (event)
+ Add(new cMenuSwitchTimerItem(switchTimer, event));
+ switchTimer = SwitchTimers.Next(switchTimer);
}
Display();
SetHelp(trVDR("Button$Edit"), tr("Button$Delete all"), trVDR("Button$Delete"), NULL);
@@ -189,26 +186,25 @@ eOSState cMenuSwitchTimers::Delete(void)
{
cSwitchTimer *curSwitchTimer = CurrentSwitchTimer();
if (curSwitchTimer) {
- if (Interface->Confirm(tr("Edit$Delete entry?"))) {
- cMutexLock SwitchTimersLock(&SwitchTimers);
- SwitchTimers.Del(curSwitchTimer);
- SwitchTimers.Save();
- cOsdMenu::Del(Current());
- Display();
- }
+ if (Interface->Confirm(tr("Edit$Delete entry?"))) {
+ cMutexLock SwitchTimersLock(&SwitchTimers);
+ SwitchTimers.Del(curSwitchTimer);
+ SwitchTimers.Save();
+ cOsdMenu::Del(Current());
+ Display();
+ }
}
return osContinue;
}
eOSState cMenuSwitchTimers::DeleteAll(void)
{
- if (Interface->Confirm(tr("Edit$Delete all entries?")))
- {
- cMutexLock SwitchTimersLock(&SwitchTimers);
- while (SwitchTimers.First())
- SwitchTimers.Del(SwitchTimers.First());
- SwitchTimers.Save();
- Set();
+ if (Interface->Confirm(tr("Edit$Delete all entries?"))) {
+ cMutexLock SwitchTimersLock(&SwitchTimers);
+ while (SwitchTimers.First())
+ SwitchTimers.Del(SwitchTimers.First());
+ SwitchTimers.Save();
+ Set();
}
return osContinue;
@@ -217,54 +213,53 @@ eOSState cMenuSwitchTimers::DeleteAll(void)
eOSState cMenuSwitchTimers::Summary(void)
{
if (HasSubMenu() || Count() == 0)
- return osContinue;
+ return osContinue;
cSwitchTimer *curSwitchTimer = CurrentSwitchTimer();
- if (curSwitchTimer)
- {
- const cEvent* event = curSwitchTimer->Event();
- if (event && !isempty(event->Description()))
- return AddSubMenu(new cMenuText(tr("Summary"), event->Description()));
+ if (curSwitchTimer) {
+ const cEvent* event = curSwitchTimer->Event();
+ if (event && !isempty(event->Description()))
+ return AddSubMenu(new cMenuText(tr("Summary"), event->Description()));
}
return osContinue;
}
eOSState cMenuSwitchTimers::ProcessKey(eKeys Key)
{
- eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown) {
- switch (Key) {
- case kOk:
- state = Summary();
- break;
- case kGreen:
- state = DeleteAll();
- break;
- case kYellow:
- state = Delete();
- break;
- case kRed:
- if (HasSubMenu())
- return osContinue;
- if (CurrentSwitchTimer())
- state = AddSubMenu(new cMenuEditSwitchTimer(CurrentSwitchTimer()));
- else
- state = osContinue;
- break;
- case k0:
- if (CurrentSwitchTimer())
- {
- cSwitchTimer* switchTimer = CurrentSwitchTimer();
- switchTimer->mode = switchTimer->mode==1?2:1;
- cMutexLock SwitchTimersLock(&SwitchTimers);
- SwitchTimers.Save();
- RefreshCurrent();
- Display();
- }
- break;
- default: break;
+ eOSState state = cOsdMenu::ProcessKey(Key);
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk:
+ state = Summary();
+ break;
+ case kGreen:
+ state = DeleteAll();
+ break;
+ case kYellow:
+ state = Delete();
+ break;
+ case kRed:
+ if (HasSubMenu())
+ return osContinue;
+ if (CurrentSwitchTimer())
+ state = AddSubMenu(new cMenuEditSwitchTimer(CurrentSwitchTimer()));
+ else
+ state = osContinue;
+ break;
+ case k0:
+ if (CurrentSwitchTimer()) {
+ cSwitchTimer* switchTimer = CurrentSwitchTimer();
+ switchTimer->mode = switchTimer->mode == 1 ? 2 : 1;
+ cMutexLock SwitchTimersLock(&SwitchTimers);
+ SwitchTimers.Save();
+ RefreshCurrent();
+ Display();
+ }
+ break;
+ default:
+ break;
+ }
}
- }
- return state;
+ return state;
}
diff --git a/menu_switchtimers.h b/menu_switchtimers.h
index 4f06e76..a80314f 100644
--- a/menu_switchtimers.h
+++ b/menu_switchtimers.h
@@ -29,8 +29,9 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "switchtimer.h"
// --- cMenuSwitchTimerItem ----------------------------------------------------------
-class cMenuSwitchTimerItem : public cOsdItem {
- public:
+class cMenuSwitchTimerItem : public cOsdItem
+{
+public:
cSwitchTimer* switchTimer;
const cEvent* event;
cMenuSwitchTimerItem(cSwitchTimer* SwitchTimer, const cEvent* event);
@@ -39,16 +40,17 @@ class cMenuSwitchTimerItem : public cOsdItem {
};
-class cMenuSwitchTimers : public cOsdMenu {
- private:
+class cMenuSwitchTimers : public cOsdMenu
+{
+private:
eOSState Delete(void);
eOSState DeleteAll(void);
- protected:
+protected:
void Set();
virtual eOSState ProcessKey(eKeys Key);
eOSState Summary(void);
cSwitchTimer* CurrentSwitchTimer(void);
- public:
+public:
cMenuSwitchTimers();
};
diff --git a/menu_templateedit.c b/menu_templateedit.c
index 20278b0..562625f 100644
--- a/menu_templateedit.c
+++ b/menu_templateedit.c
@@ -37,285 +37,244 @@ extern cChannelGroups ChannelGroups;
extern cSearchExtCats SearchExtCats;
cMenuEditTemplate::cMenuEditTemplate(cSearchExt *SearchExt, bool New)
- : cMenuEditSearchExt(SearchExt, New, true)
+ : cMenuEditSearchExt(SearchExt, New, true)
{
- SetTitle(tr("Edit template"));
+ SetTitle(tr("Edit template"));
}
eOSState cMenuEditTemplate::ProcessKey(eKeys Key)
{
- bool bHadSubMenu = HasSubMenu();
+ bool bHadSubMenu = HasSubMenu();
- int iTemp_mode = data.mode;
- int iTemp_useTime = data.useTime;
- int iTemp_useChannel = data.useChannel;
- int iTemp_useDuration = data.useDuration;
- int iTemp_useDayOfWeek = data.useDayOfWeek;
- int iTemp_useAsSearchTimer = data.useAsSearchTimer;
- int iTemp_useExtEPGInfo = data.useExtEPGInfo;
- int iTemp_avoidRepeats = data.avoidRepeats;
- int iTemp_allowedRepeats = data.allowedRepeats;
- int iTemp_delAfterDays = data.delAfterDays;
- int iTemp_delMode = data.delMode;
+ int iTemp_mode = data.mode;
+ int iTemp_useTime = data.useTime;
+ int iTemp_useChannel = data.useChannel;
+ int iTemp_useDuration = data.useDuration;
+ int iTemp_useDayOfWeek = data.useDayOfWeek;
+ int iTemp_useAsSearchTimer = data.useAsSearchTimer;
+ int iTemp_useExtEPGInfo = data.useExtEPGInfo;
+ int iTemp_avoidRepeats = data.avoidRepeats;
+ int iTemp_allowedRepeats = data.allowedRepeats;
+ int iTemp_delAfterDays = data.delAfterDays;
+ int iTemp_delMode = data.delMode;
- eOSState state = cOsdMenu::ProcessKey(Key);
+ eOSState state = cOsdMenu::ProcessKey(Key);
- if (iTemp_mode != data.mode ||
- iTemp_useTime != data.useTime ||
- iTemp_useChannel != data.useChannel ||
- iTemp_useDuration != data.useDuration ||
- iTemp_useDayOfWeek != data.useDayOfWeek ||
- iTemp_useAsSearchTimer != data.useAsSearchTimer ||
- iTemp_useExtEPGInfo != data.useExtEPGInfo ||
- iTemp_avoidRepeats != data.avoidRepeats ||
- iTemp_allowedRepeats != data.allowedRepeats||
- iTemp_delAfterDays != data.delAfterDays ||
- iTemp_delMode != data.delMode)
- {
- Set();
- Display();
- }
- const char* ItemText = Get(Current())->Text();
+ if (iTemp_mode != data.mode ||
+ iTemp_useTime != data.useTime ||
+ iTemp_useChannel != data.useChannel ||
+ iTemp_useDuration != data.useDuration ||
+ iTemp_useDayOfWeek != data.useDayOfWeek ||
+ iTemp_useAsSearchTimer != data.useAsSearchTimer ||
+ iTemp_useExtEPGInfo != data.useExtEPGInfo ||
+ iTemp_avoidRepeats != data.avoidRepeats ||
+ iTemp_allowedRepeats != data.allowedRepeats ||
+ iTemp_delAfterDays != data.delAfterDays ||
+ iTemp_delMode != data.delMode) {
+ Set();
+ Display();
+ }
+ const char* ItemText = Get(Current())->Text();
- if (!HasSubMenu())
- {
- if (strlen(ItemText)>0 && strstr(ItemText, tr(" from channel")) == ItemText && ((Key >= k0 && Key <= k9) || Key == kLeft || Key == kRight))
- {
- channelMax = channelMin;
- Set();
- Display();
- }
- }
+ if (!HasSubMenu()) {
+ if (strlen(ItemText) > 0 && strstr(ItemText, tr(" from channel")) == ItemText && ((Key >= k0 && Key <= k9) || Key == kLeft || Key == kRight)) {
+ channelMax = channelMin;
+ Set();
+ Display();
+ }
+ }
- int iOnUserDefDayItem = 0;
- int iOnDirectoryItem = 0;
- int iOnUseChannelGroups = 0;
- int iOnChannelGroup = 0;
- int iOnAvoidRepeats = 0;
- int iOnCompareCats = 0;
- int iOnUseBlacklistsSelection = 0;
- int iOnExtCatItemBrowsable = 0;
- int iOnUseAsSearchTimer = 0;
- int iCatIndex = -1;
- char* catname = NULL;
+ int iOnUserDefDayItem = 0;
+ int iOnDirectoryItem = 0;
+ int iOnUseChannelGroups = 0;
+ int iOnChannelGroup = 0;
+ int iOnAvoidRepeats = 0;
+ int iOnCompareCats = 0;
+ int iOnUseBlacklistsSelection = 0;
+ int iOnExtCatItemBrowsable = 0;
+ int iOnUseAsSearchTimer = 0;
+ int iCatIndex = -1;
+ char* catname = NULL;
- if (!HasSubMenu() && strlen(ItemText)>0)
- {
- // check, if on an item of ext. EPG info
- int iOnExtCatItem = 0;
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- if (strstr(ItemText, IndentMenuItem(SearchExtCat->menuname)) == ItemText)
- {
- iOnExtCatItem = 1;
- if (SearchExtCat->nvalues > 0)
- iOnExtCatItemBrowsable = 1;
- iCatIndex = index;
- catname = SearchExtCat->menuname;
- break;
- }
- index++;
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- }
+ if (!HasSubMenu() && strlen(ItemText) > 0) {
+ // check, if on an item of ext. EPG info
+ int iOnExtCatItem = 0;
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ if (strstr(ItemText, IndentMenuItem(SearchExtCat->menuname)) == ItemText) {
+ iOnExtCatItem = 1;
+ if (SearchExtCat->nvalues > 0)
+ iOnExtCatItemBrowsable = 1;
+ iCatIndex = index;
+ catname = SearchExtCat->menuname;
+ break;
+ }
+ index++;
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ }
- if (strstr(ItemText, IndentMenuItem(tr("Day of week"))) == ItemText)
- {
- if (data.DayOfWeek == 7)
- {
- SetHelp(trVDR("Button$Edit"));
- iOnUserDefDayItem = 1;
- }
- else
- SetHelp(NULL);
- }
- if (strstr(ItemText, tr("Use as search timer")) == ItemText)
- {
- if (data.useAsSearchTimer == 2)
- {
+ if (strstr(ItemText, IndentMenuItem(tr("Day of week"))) == ItemText) {
+ if (data.DayOfWeek == 7) {
+ SetHelp(trVDR("Button$Edit"));
+ iOnUserDefDayItem = 1;
+ } else
+ SetHelp(NULL);
+ }
+ if (strstr(ItemText, tr("Use as search timer")) == ItemText) {
+ if (data.useAsSearchTimer == 2) {
+ SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
+ iOnUseAsSearchTimer = 1;
+ } else
+ SetHelp(NULL);
+ } else if (strstr(ItemText, IndentMenuItem(tr("Directory"))) == ItemText) {
+ if (!InEditMode(ItemText, IndentMenuItem(tr("Directory")), data.directory))
+ SetHelp(NULL, NULL, NULL, tr("Button$Select"));
+ iOnDirectoryItem = 1;
+ } else if (strstr(ItemText, tr("Use channel")) == ItemText && data.useChannel == 2) {
+ SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
+ iOnUseChannelGroups = 1;
+ } else if (strstr(ItemText, IndentMenuItem(tr("Channel group"))) == ItemText) {
+ SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
+ iOnChannelGroup = 1;
+ } else if (strstr(ItemText, tr("Use blacklists")) == ItemText && data.blacklistMode == blacklistsSelection) {
SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
- iOnUseAsSearchTimer = 1;
- }
- else
- SetHelp(NULL);
- }
- else if (strstr(ItemText, IndentMenuItem(tr("Directory"))) == ItemText)
- {
- if (!InEditMode(ItemText, IndentMenuItem(tr("Directory")), data.directory))
- SetHelp(NULL, NULL, NULL, tr("Button$Select"));
- iOnDirectoryItem = 1;
- }
- else if (strstr(ItemText, tr("Use channel")) == ItemText && data.useChannel == 2)
- {
- SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
- iOnUseChannelGroups = 1;
- }
- else if (strstr(ItemText, IndentMenuItem(tr("Channel group"))) == ItemText)
- {
- SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
- iOnChannelGroup = 1;
- }
- else if (strstr(ItemText, tr("Use blacklists")) == ItemText && data.blacklistMode == blacklistsSelection)
- {
- SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
- iOnUseBlacklistsSelection = 1;
- }
- else if (strstr(ItemText, IndentMenuItem(tr("Avoid repeats"))) == ItemText)
- {
- SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
- iOnAvoidRepeats = 1;
- }
- else if (strstr(ItemText, IndentMenuItem(IndentMenuItem(tr("Compare categories")))) == ItemText)
- {
- SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
- iOnCompareCats = 1;
- }
- else if (iOnExtCatItem)
- {
- if (!InEditMode(ItemText, IndentMenuItem(catname), data.catvalues[iCatIndex]) ||
- SearchExtCats.Get(iCatIndex)->searchmode >= 10)
- SetHelp(NULL, NULL, NULL, iOnExtCatItemBrowsable?tr("Button$Select"):NULL);
- }
- else if (strstr(ItemText, tr("Template name")) != ItemText)
- SetHelp(NULL, NULL, NULL, NULL);
- }
- if (state == osUnknown) {
- if (HasSubMenu())
- return osContinue;
- switch (Key) {
- case kOk:
- if (data.useChannel==1)
- {
- LOCK_CHANNELS_READ;
- const cChannel *ch = Channels->GetByNumber(channelMin);
- if (ch)
- data.channelMin = ch;
- else
- {
- ERROR(tr("*** Invalid Channel ***"));
- break;
- }
- ch = Channels->GetByNumber(channelMax);
- if (ch)
- data.channelMax = ch;
- else
- {
- ERROR(tr("*** Invalid Channel ***"));
- break;
- }
- if (channelMin > channelMax)
- {
- ERROR(tr("Please check channel criteria!"));
- return osContinue;
- }
+ iOnUseBlacklistsSelection = 1;
+ } else if (strstr(ItemText, IndentMenuItem(tr("Avoid repeats"))) == ItemText) {
+ SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
+ iOnAvoidRepeats = 1;
+ } else if (strstr(ItemText, IndentMenuItem(IndentMenuItem(tr("Compare categories")))) == ItemText) {
+ SetHelp(NULL, NULL, NULL, tr("Button$Setup"));
+ iOnCompareCats = 1;
+ } else if (iOnExtCatItem) {
+ if (!InEditMode(ItemText, IndentMenuItem(catname), data.catvalues[iCatIndex]) ||
+ SearchExtCats.Get(iCatIndex)->searchmode >= 10)
+ SetHelp(NULL, NULL, NULL, iOnExtCatItemBrowsable ? tr("Button$Select") : NULL);
+ } else if (strstr(ItemText, tr("Template name")) != ItemText)
+ SetHelp(NULL, NULL, NULL, NULL);
+ }
+ if (state == osUnknown) {
+ if (HasSubMenu())
+ return osContinue;
+ switch (Key) {
+ case kOk:
+ if (data.useChannel == 1) {
+ LOCK_CHANNELS_READ;
+ const cChannel *ch = Channels->GetByNumber(channelMin);
+ if (ch)
+ data.channelMin = ch;
+ else {
+ ERROR(tr("*** Invalid Channel ***"));
+ break;
+ }
+ ch = Channels->GetByNumber(channelMax);
+ if (ch)
+ data.channelMax = ch;
+ else {
+ ERROR(tr("*** Invalid Channel ***"));
+ break;
+ }
+ if (channelMin > channelMax) {
+ ERROR(tr("Please check channel criteria!"));
+ return osContinue;
+ }
}
- if (data.useChannel==2)
- data.channelGroup = strdup(menuitemsChGr[channelGroupNr]);
+ if (data.useChannel == 2)
+ data.channelGroup = strdup(menuitemsChGr[channelGroupNr]);
- if (searchExt)
- {
- *searchExt = data;
- if (data.DayOfWeek == 7)
- searchExt->DayOfWeek = UserDefDayOfWeek;
+ if (searchExt) {
+ *searchExt = data;
+ if (data.DayOfWeek == 7)
+ searchExt->DayOfWeek = UserDefDayOfWeek;
- // transfer cat selection for 'avoid repeats' back to search
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- searchExt->catvaluesAvoidRepeat = 0;
- while (SearchExtCat)
- {
- if (catarrayAvoidRepeats[index])
- searchExt->catvaluesAvoidRepeat += (1<<index);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
+ // transfer cat selection for 'avoid repeats' back to search
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ searchExt->catvaluesAvoidRepeat = 0;
+ while (SearchExtCat) {
+ if (catarrayAvoidRepeats[index])
+ searchExt->catvaluesAvoidRepeat += (1 << index);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
- // transfer numeric cat values back to search
- SearchExtCat = SearchExtCats.First();
- index = 0;
- while (SearchExtCat)
- {
- if (SearchExtCat->searchmode >= 10)
- {
- if (searchExt->catvalues[index]) free(searchExt->catvalues[index]);
- msprintf(&searchExt->catvalues[index], "%d", catvaluesNumeric[index]);
- }
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
+ // transfer numeric cat values back to search
+ SearchExtCat = SearchExtCats.First();
+ index = 0;
+ while (SearchExtCat) {
+ if (SearchExtCat->searchmode >= 10) {
+ if (searchExt->catvalues[index]) free(searchExt->catvalues[index]);
+ msprintf(&searchExt->catvalues[index], "%d", catvaluesNumeric[index]);
+ }
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
- if (data.blacklistMode == blacklistsSelection)
- {
- searchExt->blacklists.Clear();
- cBlacklistObject* blacklistObj = blacklists.First();
- while(blacklistObj)
- {
- searchExt->blacklists.Add(new cBlacklistObject(blacklistObj->blacklist));
- blacklistObj = blacklists.Next(blacklistObj);
- }
- }
- else
- searchExt->blacklists.Clear();
+ if (data.blacklistMode == blacklistsSelection) {
+ searchExt->blacklists.Clear();
+ cBlacklistObject* blacklistObj = blacklists.First();
+ while (blacklistObj) {
+ searchExt->blacklists.Add(new cBlacklistObject(blacklistObj->blacklist));
+ blacklistObj = blacklists.Next(blacklistObj);
+ }
+ } else
+ searchExt->blacklists.Clear();
- if (addIfConfirmed)
- {
- cMutexLock SearchTemplatesLock(&SearchTemplates);
- searchExt->ID = SearchTemplates.GetNewID();
- SearchTemplates.Add(searchExt);
- }
- SearchTemplates.Save();
- addIfConfirmed = false;
+ if (addIfConfirmed) {
+ cMutexLock SearchTemplatesLock(&SearchTemplates);
+ searchExt->ID = SearchTemplates.GetNewID();
+ SearchTemplates.Add(searchExt);
+ }
+ SearchTemplates.Save();
+ addIfConfirmed = false;
}
return osBack;
- case kRed:
+ case kRed:
if (iOnUserDefDayItem)
- state = AddSubMenu(new cMenuEditDaysOfWeek(&UserDefDayOfWeek));
+ state = AddSubMenu(new cMenuEditDaysOfWeek(&UserDefDayOfWeek));
break;
- case kBlue:
+ case kBlue:
if (iOnDirectoryItem && !InEditMode(ItemText, IndentMenuItem(tr("Directory")), data.directory))
- state = AddSubMenu(new cMenuDirSelect(data.directory));
- if (iOnUseChannelGroups || iOnChannelGroup)
- {
- if (channelGroupName)
- free(channelGroupName);
- channelGroupName = strdup(menuitemsChGr[channelGroupNr]);
- state = AddSubMenu(new cMenuChannelGroups(&channelGroupName));
+ state = AddSubMenu(new cMenuDirSelect(data.directory));
+ if (iOnUseChannelGroups || iOnChannelGroup) {
+ if (channelGroupName)
+ free(channelGroupName);
+ channelGroupName = strdup(menuitemsChGr[channelGroupNr]);
+ state = AddSubMenu(new cMenuChannelGroups(&channelGroupName));
}
if (iOnAvoidRepeats)
- state = AddSubMenu(new cMenuRecsDone(searchExt));
+ state = AddSubMenu(new cMenuRecsDone(searchExt));
if (iOnCompareCats)
- state = AddSubMenu(new cMenuSearchEditCompCats(catarrayAvoidRepeats));
+ state = AddSubMenu(new cMenuSearchEditCompCats(catarrayAvoidRepeats));
if (iOnUseBlacklistsSelection)
- state = AddSubMenu(new cMenuBlacklistsSelection(&blacklists));
+ state = AddSubMenu(new cMenuBlacklistsSelection(&blacklists));
if (iOnExtCatItemBrowsable)
- state = AddSubMenu(new cMenuCatValuesSelect(data.catvalues[iCatIndex], iCatIndex, SearchExtCats.Get(iCatIndex)->searchmode));
- if (iOnUseAsSearchTimer)
- state = AddSubMenu(new cMenuSearchActivSettings(&data));
+ state = AddSubMenu(new cMenuCatValuesSelect(data.catvalues[iCatIndex], iCatIndex, SearchExtCats.Get(iCatIndex)->searchmode));
+ if (iOnUseAsSearchTimer)
+ state = AddSubMenu(new cMenuSearchActivSettings(&data));
+ break;
+ case kGreen:
+ case kYellow:
+ state = osContinue;
+ default:
break;
- case kGreen:
- case kYellow: state = osContinue;
- default: break;
- }
- }
- if ((iOnUseChannelGroups || iOnChannelGroup || iOnCompareCats || iOnExtCatItemBrowsable) && bHadSubMenu && !HasSubMenu()) // return form submenu
- {
- if (iOnExtCatItemBrowsable && SearchExtCats.Count() > 0)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- if (SearchExtCat->searchmode >= 10)
- catvaluesNumeric[index] = atoi(data.catvalues[index]);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
+ }
+ }
+ if ((iOnUseChannelGroups || iOnChannelGroup || iOnCompareCats || iOnExtCatItemBrowsable) && bHadSubMenu && !HasSubMenu()) { // return form submenu
+ if (iOnExtCatItemBrowsable && SearchExtCats.Count() > 0) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ if (SearchExtCat->searchmode >= 10)
+ catvaluesNumeric[index] = atoi(data.catvalues[index]);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
}
- }
- Set();
- Display();
- }
- return state;
+ }
+ Set();
+ Display();
+ }
+ return state;
}
diff --git a/menu_templateedit.h b/menu_templateedit.h
index 81615a1..62ba06c 100644
--- a/menu_templateedit.h
+++ b/menu_templateedit.h
@@ -27,10 +27,11 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "menu_searchedit.h"
// --- cMenuEditTemplate --------------------------------------------------------
-class cMenuEditTemplate: public cMenuEditSearchExt {
- public:
- cMenuEditTemplate(cSearchExt *SearchExt, bool New = false);
- virtual eOSState ProcessKey(eKeys Key);
+class cMenuEditTemplate: public cMenuEditSearchExt
+{
+public:
+ cMenuEditTemplate(cSearchExt *SearchExt, bool New = false);
+ virtual eOSState ProcessKey(eKeys Key);
};
#endif
diff --git a/menu_timersdone.c b/menu_timersdone.c
index 5120bad..8f41bb7 100644
--- a/menu_timersdone.c
+++ b/menu_timersdone.c
@@ -29,194 +29,189 @@ int sortModeTimerDone = 0;
cMenuTimerDoneItem::cMenuTimerDoneItem(cTimerDone* TimerDone)
{
- timerDone = TimerDone;
- Set();
+ timerDone = TimerDone;
+ Set();
}
void cMenuTimerDoneItem::Set(void)
{
- if (!timerDone)
- return;
- char *buffer = NULL;
-
- char buf[32];
- struct tm tm_r;
- tm *tm = localtime_r(&timerDone->start, &tm_r);
- strftime(buf, sizeof(buf), "%d.%m.%y %H:%M", tm);
-
- LOCK_CHANNELS_READ;
- const cChannel* ch = Channels->GetByChannelID(timerDone->channelID, true, true);
- msprintf(&buffer, "%d\t%s\t%s~%s", ch?ch->Number():0, buf, timerDone->title.c_str(), timerDone->shorttext.c_str());
- SetText(buffer, false);
+ if (!timerDone)
+ return;
+ char *buffer = NULL;
+
+ char buf[32];
+ struct tm tm_r;
+ tm *tm = localtime_r(&timerDone->start, &tm_r);
+ strftime(buf, sizeof(buf), "%d.%m.%y %H:%M", tm);
+
+ LOCK_CHANNELS_READ;
+ const cChannel* ch = Channels->GetByChannelID(timerDone->channelID, true, true);
+ msprintf(&buffer, "%d\t%s\t%s~%s", ch ? ch->Number() : 0, buf, timerDone->title.c_str(), timerDone->shorttext.c_str());
+ SetText(buffer, false);
}
int cMenuTimerDoneItem::Compare(const cListObject &ListObject) const
{
- cMenuTimerDoneItem *p = (cMenuTimerDoneItem *)&ListObject;
- if (sortModeTimerDone == 0) // sort by Date
- if (timerDone->start > p->timerDone->start) return 1; else return -1;
- else
- {
- cString s1 = cString::sprintf("%s~%s", timerDone->title.c_str(), timerDone->shorttext.c_str());
- cString s2 = cString::sprintf("%s~%s", p->timerDone->title.c_str(), p->timerDone->shorttext.c_str());
- int res = strcasecmp(s1, s2);
- return res;
- }
+ cMenuTimerDoneItem *p = (cMenuTimerDoneItem *)&ListObject;
+ if (sortModeTimerDone == 0) // sort by Date
+ if (timerDone->start > p->timerDone->start) return 1;
+ else return -1;
+ else {
+ cString s1 = cString::sprintf("%s~%s", timerDone->title.c_str(), timerDone->shorttext.c_str());
+ cString s2 = cString::sprintf("%s~%s", p->timerDone->title.c_str(), p->timerDone->shorttext.c_str());
+ int res = strcasecmp(s1, s2);
+ return res;
+ }
}
// --- cMenuTimersDone ----------------------------------------------------------
cMenuTimersDone::cMenuTimersDone(cSearchExt* Search)
-:cOsdMenu("", 4, 15)
+ : cOsdMenu("", 4, 15)
{
- SetMenuCategory(mcTimer);
-
- search = Search;
- showAll = true;
- sortModeTimerDone = 0;
- if (search) showAll = false;
- Set();
- Display();
+ SetMenuCategory(mcTimer);
+
+ search = Search;
+ showAll = true;
+ sortModeTimerDone = 0;
+ if (search) showAll = false;
+ Set();
+ Display();
}
void cMenuTimersDone::Set()
{
- Clear();
- eventObjects.Clear();
- cMutexLock TimersDoneLock(&TimersDone);
- cTimerDone* timerDone = TimersDone.First();
- while (timerDone) {
- if (showAll || (!showAll && search && timerDone->searchID == search->ID))
- Add(new cMenuTimerDoneItem(timerDone));
- timerDone = TimersDone.Next(timerDone);
- }
- UpdateTitle();
- SetHelp(sortModeTimerDone==0?tr("Button$by name"):tr("Button$by date"), tr("Button$Delete all"), trVDR("Button$Delete"), showAll?search->search:tr("Button$Show all"));
- Sort();
-
- cMenuTimerDoneItem* item = (cMenuTimerDoneItem*)First();
- while(item)
- {
- if (item->timerDone)
- {
- const cEvent* Event = item->timerDone->GetEvent();
- if (Event) eventObjects.Add(Event);
- }
- item = (cMenuTimerDoneItem*)Next(item);
- }
+ Clear();
+ eventObjects.Clear();
+ cMutexLock TimersDoneLock(&TimersDone);
+ cTimerDone* timerDone = TimersDone.First();
+ while (timerDone) {
+ if (showAll || (!showAll && search && timerDone->searchID == search->ID))
+ Add(new cMenuTimerDoneItem(timerDone));
+ timerDone = TimersDone.Next(timerDone);
+ }
+ UpdateTitle();
+ SetHelp(sortModeTimerDone == 0 ? tr("Button$by name") : tr("Button$by date"), tr("Button$Delete all"), trVDR("Button$Delete"), showAll ? search->search : tr("Button$Show all"));
+ Sort();
+
+ cMenuTimerDoneItem* item = (cMenuTimerDoneItem*)First();
+ while (item) {
+ if (item->timerDone) {
+ const cEvent* Event = item->timerDone->GetEvent();
+ if (Event) eventObjects.Add(Event);
+ }
+ item = (cMenuTimerDoneItem*)Next(item);
+ }
}
void cMenuTimersDone::UpdateCurrent()
{
- // navigation in summary could have changed current item, so update it
- cEventObj* cureventObj = eventObjects.GetCurrent();
- if (cureventObj && cureventObj->Event())
- for (cMenuTimerDoneItem *item = (cMenuTimerDoneItem *)First(); item; item = (cMenuTimerDoneItem *)Next(item))
- if (item->Selectable() && item->timerDone->GetEvent() == cureventObj->Event())
- {
- cureventObj->Select(false);
- SetCurrent(item);
- Display();
- break;
- }
+ // navigation in summary could have changed current item, so update it
+ cEventObj* cureventObj = eventObjects.GetCurrent();
+ if (cureventObj && cureventObj->Event())
+ for (cMenuTimerDoneItem *item = (cMenuTimerDoneItem *)First(); item; item = (cMenuTimerDoneItem *)Next(item))
+ if (item->Selectable() && item->timerDone->GetEvent() == cureventObj->Event()) {
+ cureventObj->Select(false);
+ SetCurrent(item);
+ Display();
+ break;
+ }
}
cTimerDone *cMenuTimersDone::CurrentTimerDone(void)
{
- cMenuTimerDoneItem *item = (cMenuTimerDoneItem *)Get(Current());
- return item ? item->timerDone : NULL;
+ cMenuTimerDoneItem *item = (cMenuTimerDoneItem *)Get(Current());
+ return item ? item->timerDone : NULL;
}
void cMenuTimersDone::UpdateTitle()
{
- cString buffer = cString::sprintf("%d %s%s%s", Count(), tr("Timers"), showAll?"":" ", showAll?"":search->search);
- SetTitle(buffer);
- Display();
+ cString buffer = cString::sprintf("%d %s%s%s", Count(), tr("Timers"), showAll ? "" : " ", showAll ? "" : search->search);
+ SetTitle(buffer);
+ Display();
}
eOSState cMenuTimersDone::Delete(void)
{
- cTimerDone *curTimerDone = CurrentTimerDone();
- if (curTimerDone) {
- if (Interface->Confirm(tr("Edit$Delete entry?"))) {
- LogFile.Log(1,"deleted timer done: '%s~%s'", curTimerDone->title!=""?curTimerDone->title.c_str():"unknown title", curTimerDone->shorttext!=""?curTimerDone->shorttext.c_str():"unknown subtitle");
- cMutexLock TimersDoneLock(&TimersDone);
- TimersDone.Del(curTimerDone);
- TimersDone.Save();
- cOsdMenu::Del(Current());
- Display();
- UpdateTitle();
- }
- }
- return osContinue;
+ cTimerDone *curTimerDone = CurrentTimerDone();
+ if (curTimerDone) {
+ if (Interface->Confirm(tr("Edit$Delete entry?"))) {
+ LogFile.Log(1, "deleted timer done: '%s~%s'", curTimerDone->title != "" ? curTimerDone->title.c_str() : "unknown title", curTimerDone->shorttext != "" ? curTimerDone->shorttext.c_str() : "unknown subtitle");
+ cMutexLock TimersDoneLock(&TimersDone);
+ TimersDone.Del(curTimerDone);
+ TimersDone.Save();
+ cOsdMenu::Del(Current());
+ Display();
+ UpdateTitle();
+ }
+ }
+ return osContinue;
}
eOSState cMenuTimersDone::DeleteAll(void)
{
- if (Interface->Confirm(tr("Edit$Delete all entries?"))) {
- cMutexLock TimersDoneLock(&TimersDone);
- while(Count()>0)
- {
- cMenuTimerDoneItem *item = (cMenuTimerDoneItem *)Get(0);
- if (!item) break;
- cTimerDone *curTimerDone = item->timerDone;
- TimersDone.Del(curTimerDone);
- cOsdMenu::Del(0);
- }
- TimersDone.Save();
- Display();
- UpdateTitle();
- }
-
- return osContinue;
+ if (Interface->Confirm(tr("Edit$Delete all entries?"))) {
+ cMutexLock TimersDoneLock(&TimersDone);
+ while (Count() > 0) {
+ cMenuTimerDoneItem *item = (cMenuTimerDoneItem *)Get(0);
+ if (!item) break;
+ cTimerDone *curTimerDone = item->timerDone;
+ TimersDone.Del(curTimerDone);
+ cOsdMenu::Del(0);
+ }
+ TimersDone.Save();
+ Display();
+ UpdateTitle();
+ }
+
+ return osContinue;
}
eOSState cMenuTimersDone::ProcessKey(eKeys Key)
{
- bool HadSubMenu = HasSubMenu();
- eOSState state = cOsdMenu::ProcessKey(Key);
- if (!HasSubMenu() && HadSubMenu)
- UpdateCurrent();
-
- if (state == osUnknown) {
- switch (Key) {
- case kGreen:
+ bool HadSubMenu = HasSubMenu();
+ eOSState state = cOsdMenu::ProcessKey(Key);
+ if (!HasSubMenu() && HadSubMenu)
+ UpdateCurrent();
+
+ if (state == osUnknown) {
+ switch (Key) {
+ case kGreen:
state = DeleteAll();
break;
- case kYellow:
+ case kYellow:
state = Delete();
break;
- case kBlue:
- if(!HasSubMenu()) {
- showAll = !showAll;
- Set();
- Display();
+ case kBlue:
+ if (!HasSubMenu()) {
+ showAll = !showAll;
+ Set();
+ Display();
}
break;
- case k0:
- case kRed:
- if(!HasSubMenu()) {
- sortModeTimerDone = 1-sortModeTimerDone;
- Set();
- Display();
+ case k0:
+ case kRed:
+ if (!HasSubMenu()) {
+ sortModeTimerDone = 1 - sortModeTimerDone;
+ Set();
+ Display();
}
break;
- case k8:
+ case k8:
return osContinue;
- case kOk:
- {
+ case kOk: {
cTimerDone *TimerDone = CurrentTimerDone();
- if (TimerDone)
- {
- const cEvent* Event = TimerDone->GetEvent();
- if (!Event) break;
- return AddSubMenu(new cMenuEventSearchSimple(Event, eventObjects));
- }
- }
- default: break;
- }
- }
-
- return state;
+ if (TimerDone) {
+ const cEvent* Event = TimerDone->GetEvent();
+ if (!Event) break;
+ return AddSubMenu(new cMenuEventSearchSimple(Event, eventObjects));
+ }
+ }
+ default:
+ break;
+ }
+ }
+
+ return state;
}
diff --git a/menu_timersdone.h b/menu_timersdone.h
index a48cadd..cfaff2f 100644
--- a/menu_timersdone.h
+++ b/menu_timersdone.h
@@ -32,8 +32,9 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
// --- cMenuTimerDoneItem ----------------------------------------------------------
-class cMenuTimerDoneItem : public cOsdItem {
- public:
+class cMenuTimerDoneItem : public cOsdItem
+{
+public:
cTimerDone* timerDone;
cMenuTimerDoneItem(cTimerDone* TimerDone);
void Set(void);
@@ -41,21 +42,22 @@ class cMenuTimerDoneItem : public cOsdItem {
};
-class cMenuTimersDone : public cOsdMenu {
- private:
+class cMenuTimersDone : public cOsdMenu
+{
+private:
cSearchExt* search;
eOSState Delete(void);
eOSState DeleteAll(void);
bool showAll;
- cEventObjects eventObjects;
- protected:
+ cEventObjects eventObjects;
+protected:
void Set();
virtual eOSState ProcessKey(eKeys Key);
void UpdateTitle();
eOSState Summary(void);
cTimerDone* CurrentTimerDone(void);
void UpdateCurrent();
- public:
+public:
cMenuTimersDone(cSearchExt* search = NULL);
};
diff --git a/menu_whatson.c b/menu_whatson.c
index 7f7dab3..9384205 100644
--- a/menu_whatson.c
+++ b/menu_whatson.c
@@ -57,245 +57,222 @@ int gl_InfoConflict = 0;
// --- cMenuMyScheduleItem ------------------------------------------------------
cMenuMyScheduleItem::cMenuMyScheduleItem(const cTimers *Timers, const cEvent *Event, const cChannel *Channel, showMode Mode, cMenuTemplate* MenuTemplate)
{
- event = Event;
- channel = Channel;
- mode = Mode;
- timerMatch = tmNone;
- isRemote = false;
- inSwitchList = false;
- timerActive = false;
- menuTemplate = MenuTemplate;
- Update(Timers, true);
+ event = Event;
+ channel = Channel;
+ mode = Mode;
+ timerMatch = tmNone;
+ isRemote = false;
+ inSwitchList = false;
+ timerActive = false;
+ menuTemplate = MenuTemplate;
+ Update(Timers, true);
}
bool cMenuMyScheduleItem::Update(const cTimers* Timers, bool Force)
{
- if (!menuTemplate)
- return false;
-
- const char* menutemplate = menuTemplate->MenuTemplate();
- if (!menutemplate || strlen(menutemplate) == 0)
- return false;
-
- bool result = false;
-
- eTimerMatch OldTimerMatch = timerMatch;
- bool OldIsRemote = isRemote;
- bool OldInSwitchList = inSwitchList;
- bool OldtimerActive = timerActive;
- bool hasMatch = false;
- const cTimer* timer = NULL;
- if (event) timer = Timers->GetMatch(event, &timerMatch);
- if (event) inSwitchList = (SwitchTimers.InSwitchList(event)!=NULL);
- if (timer) hasMatch = true;
- if (timer) timerActive = timer->HasFlags(tfActive);
- if (timer) isRemote = timer->Remote();
-
- if (Force || timerMatch != OldTimerMatch || inSwitchList != OldInSwitchList
- || isRemote != OldIsRemote || timerActive != OldtimerActive)
- {
- char szProgressPart[Utf8BufSize(12)] = "";
- char szProgressPartT2S[12] = "";
- time_t now = time(NULL);
- if (channel)
- {
- if (event)
- {
- time_t startTime = event->StartTime();
- if ((now - event->StartTime()) >= 0 || strstr(menutemplate, "%time%") != NULL)
- {
- int frac = 0;
- if (mode == showNow)
- {
- int dur = event->Duration();
- if (dur != 0)
- frac = ((now - startTime) * 8 + (dur >> 1)) / dur;
- }
- if (mode == showNext)
- frac = ( ( 30*60 - std::min((time_t)30*60, startTime - now) ) * 8 + 15*60 ) / (30*60);
-
- frac = std::min(8,std::max(0, frac));
-
- szProgressPartT2S[0] = '[';
- memset(szProgressPartT2S + 1,'|',frac);
- memset(szProgressPartT2S + 1 + frac ,' ', 8 - frac);
- szProgressPartT2S[9] = ']';
- szProgressPartT2S[10] = 0;
-
- if (!isUTF8)
- {
- szProgressPart[0] = ICON_BAR_OPEN;
- memset(szProgressPart + 1, ICON_BAR_EMPTY, 6);
- szProgressPart[7] = ICON_BAR_CLOSE;
- szProgressPart[8] = 0;
- memset(szProgressPart, ICON_BAR_FULL, frac?frac:sizeof(szProgressPart));
- }
- else
- {
+ if (!menuTemplate)
+ return false;
+
+ const char* menutemplate = menuTemplate->MenuTemplate();
+ if (!menutemplate || strlen(menutemplate) == 0)
+ return false;
+
+ bool result = false;
+
+ eTimerMatch OldTimerMatch = timerMatch;
+ bool OldIsRemote = isRemote;
+ bool OldInSwitchList = inSwitchList;
+ bool OldtimerActive = timerActive;
+ bool hasMatch = false;
+ const cTimer* timer = NULL;
+ if (event) timer = Timers->GetMatch(event, &timerMatch);
+ if (event) inSwitchList = (SwitchTimers.InSwitchList(event) != NULL);
+ if (timer) hasMatch = true;
+ if (timer) timerActive = timer->HasFlags(tfActive);
+ if (timer) isRemote = timer->Remote();
+
+ if (Force || timerMatch != OldTimerMatch || inSwitchList != OldInSwitchList
+ || isRemote != OldIsRemote || timerActive != OldtimerActive) {
+ char szProgressPart[Utf8BufSize(12)] = "";
+ char szProgressPartT2S[12] = "";
+ time_t now = time(NULL);
+ if (channel) {
+ if (event) {
+ time_t startTime = event->StartTime();
+ if ((now - event->StartTime()) >= 0 || strstr(menutemplate, "%time%") != NULL) {
+ int frac = 0;
+ if (mode == showNow) {
+ int dur = event->Duration();
+ if (dur != 0)
+ frac = ((now - startTime) * 8 + (dur >> 1)) / dur;
+ }
+ if (mode == showNext)
+ frac = ((30 * 60 - std::min((time_t)30 * 60, startTime - now)) * 8 + 15 * 60) / (30 * 60);
+
+ frac = std::min(8, std::max(0, frac));
+
+ szProgressPartT2S[0] = '[';
+ memset(szProgressPartT2S + 1, '|', frac);
+ memset(szProgressPartT2S + 1 + frac , ' ', 8 - frac);
+ szProgressPartT2S[9] = ']';
+ szProgressPartT2S[10] = 0;
+
+ if (!isUTF8) {
+ szProgressPart[0] = ICON_BAR_OPEN;
+ memset(szProgressPart + 1, ICON_BAR_EMPTY, 6);
+ szProgressPart[7] = ICON_BAR_CLOSE;
+ szProgressPart[8] = 0;
+ memset(szProgressPart, ICON_BAR_FULL, frac ? frac : sizeof(szProgressPart));
+ } else {
#if defined(__GNUC__) && __GNUC__ < 3 && __GNUC_MINOR__ < 96
#else
- std::stringstream buffer;
- buffer << ICON_BAR_OPEN_UTF8;
- for(int i=0;i<8;i++) buffer << (i<frac?ICON_BAR_FULL_UTF8:ICON_BAR_EMPTY_UTF8);
- buffer << ICON_BAR_CLOSE_UTF8;
- char* temp = strdup(buffer.str().c_str());
- sprintf(szProgressPart, "%s", temp);
- free(temp);
+ std::stringstream buffer;
+ buffer << ICON_BAR_OPEN_UTF8;
+ for (int i = 0; i < 8; i++) buffer << (i < frac ? ICON_BAR_FULL_UTF8 : ICON_BAR_EMPTY_UTF8);
+ buffer << ICON_BAR_CLOSE_UTF8;
+ char* temp = strdup(buffer.str().c_str());
+ sprintf(szProgressPart, "%s", temp);
+ free(temp);
#endif
- }
+ }
+ } else {
+ strncpy(szProgressPart, *event->GetTimeString(), 12);
+ szProgressPart[11] = 0;
+ memcpy(szProgressPartT2S, szProgressPart, 12);
+ }
}
- else
- {
- strncpy(szProgressPart, *event->GetTimeString(), 12);
- szProgressPart[11] = 0;
- memcpy(szProgressPartT2S, szProgressPart, 12);
- }
- }
- }
-
- char t[Utf8BufSize(2)],v[Utf8BufSize(2)],r[Utf8BufSize(2)];
- char szStatus[Utf8BufSize(4)];
- szStatus[3] = 0;
- t[1]=v[1]=r[1] = 0;
-
- if (EPGSearchConfig.WarEagle)
- {
- if (!isUTF8)
- {
- t[0] = event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? ICON_REC : (timerActive ? ICON_CLOCK : ICON_TIMER_INACT)) : (timerActive ? ICON_CLOCK_HALF : ' ' ): ' ';
- v[0] = event && event->Vps() && (event->Vps() - event->StartTime()) ? ICON_VPS : ' ';
- r[0] = event && event->IsRunning() ? ICON_RUNNING : ' ';
- }
- else
- {
+ }
+
+ char t[Utf8BufSize(2)], v[Utf8BufSize(2)], r[Utf8BufSize(2)];
+ char szStatus[Utf8BufSize(4)];
+ szStatus[3] = 0;
+ t[1] = v[1] = r[1] = 0;
+
+ if (EPGSearchConfig.WarEagle) {
+ if (!isUTF8) {
+ t[0] = event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? ICON_REC : (timerActive ? ICON_CLOCK : ICON_TIMER_INACT)) : (timerActive ? ICON_CLOCK_HALF : ' ') : ' ';
+ v[0] = event && event->Vps() && (event->Vps() - event->StartTime()) ? ICON_VPS : ' ';
+ r[0] = event && event->IsRunning() ? ICON_RUNNING : ' ';
+ } else {
#if defined(__GNUC__) && __GNUC__ < 3 && __GNUC_MINOR__ < 96
#else
- sprintf(t, "%s", (event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? ICON_REC_UTF8 : (timerActive ? ICON_CLOCK_UTF8 : ICON_TIMER_INACT_UTF8)) : (timerActive ? ICON_CLOCK_HALF_UTF8 : " ") : " "));
- sprintf(v, "%s", event && event->Vps() && (event->Vps() - event->StartTime()) ? ICON_VPS_UTF8 : " ");
- sprintf(r, "%s", (event && event->IsRunning() ? ICON_RUNNING_UTF8 : " "));
+ sprintf(t, "%s", (event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? ICON_REC_UTF8 : (timerActive ? ICON_CLOCK_UTF8 : ICON_TIMER_INACT_UTF8)) : (timerActive ? ICON_CLOCK_HALF_UTF8 : " ") : " "));
+ sprintf(v, "%s", event && event->Vps() && (event->Vps() - event->StartTime()) ? ICON_VPS_UTF8 : " ");
+ sprintf(r, "%s", (event && event->IsRunning() ? ICON_RUNNING_UTF8 : " "));
#endif
- }
- }
- else
- {
- t[0] = event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? 'R' : (timerActive ? 'T' : 'i')) : (timerActive ? 't' : ' ') : ' ';
- v[0] = event && event->Vps() && (event->Vps() - event->StartTime()) ? 'V' : ' ';
- r[0] = event && event->IsRunning() ? '*' : ' ';
- }
-
- if (event && inSwitchList)
- {
- cSwitchTimer* s = SwitchTimers.InSwitchList(event);
- t[0] = (s && s->mode==1)?'s':'S';
- }
- if (EPGSearchConfig.WarEagle && isUTF8)
- {
- std::stringstream buffer;
- buffer << t << v << r;
- char* temp = strdup(buffer.str().c_str());
- sprintf(szStatus, "%s", temp);
- free(temp);
- }
- else
- {
- szStatus[0] = t[0];
- szStatus[1] = v[0];
- szStatus[2] = r[0];
- }
-
- char* buffer = strdup(menutemplate);
- strreplace(buffer, '|', '\t');
-
- char* title = NULL;
- title = strdup(event?event->Title():tr(">>> no info! <<<"));
-
- title = strreplacei(title, ":", "%colon%"); // assume a title has the form "a?b:c",
- // we need to replace the colon to avoid misinterpretation of the expression as a condition
- buffer = strreplacei(buffer, "%title%", title);
- free(title);
-
- if (channel)
- {
- char szChannelNr[6] = "";
- snprintf(szChannelNr, 6, "%d", channel->Number());
- buffer = strreplacei(buffer, "%chnr%", szChannelNr);
- buffer = strreplacei(buffer, "%chsh%", channel->ShortName(true));
- buffer = strreplacei(buffer, "%chlng%", channel->Name());
- buffer = strreplacei(buffer, "%progr%", szProgressPart);
- buffer = strreplacei(buffer, "%progrT2S%", szProgressPartT2S);
- }
-
- // parse the epxression and evaluate it
- cVarExpr varExpr(buffer);
- char* tmp = strdup(varExpr.Evaluate(event).c_str());
- free(buffer);
- buffer = tmp;
-
- buffer = strreplacei(buffer, "$status$", szStatus);
- buffer = strreplacei(buffer, "$t_status$", t);
- buffer = strreplacei(buffer, "$v_status$", v);
- buffer = strreplacei(buffer, "$r_status$", r);
-
- buffer = FixSeparators(buffer, '~');
- buffer = FixSeparators(buffer, ':');
- buffer = FixSeparators(buffer, '-');
-
- SetText(buffer, false);
-
- if (gl_InfoConflict == 0 && EPGSearchConfig.checkTimerConflAfterTimerProg && !Force && timer && ((timerMatch && timerMatch != OldTimerMatch) || (isRemote != OldIsRemote)))
- {
- cConflictCheck C;
- C.Check();
- if (C.TimerInConflict(timer))
- gl_InfoConflict = 1;
- }
- return true;
- }
- return result;
+ }
+ } else {
+ t[0] = event && hasMatch ? (timerMatch == tmFull) ? ((timer && timer->Recording()) ? 'R' : (timerActive ? 'T' : 'i')) : (timerActive ? 't' : ' ') : ' ';
+ v[0] = event && event->Vps() && (event->Vps() - event->StartTime()) ? 'V' : ' ';
+ r[0] = event && event->IsRunning() ? '*' : ' ';
+ }
+
+ if (event && inSwitchList) {
+ cSwitchTimer* s = SwitchTimers.InSwitchList(event);
+ t[0] = (s && s->mode == 1) ? 's' : 'S';
+ }
+ if (EPGSearchConfig.WarEagle && isUTF8) {
+ std::stringstream buffer;
+ buffer << t << v << r;
+ char* temp = strdup(buffer.str().c_str());
+ sprintf(szStatus, "%s", temp);
+ free(temp);
+ } else {
+ szStatus[0] = t[0];
+ szStatus[1] = v[0];
+ szStatus[2] = r[0];
+ }
+
+ char* buffer = strdup(menutemplate);
+ strreplace(buffer, '|', '\t');
+
+ char* title = NULL;
+ title = strdup(event ? event->Title() : tr(">>> no info! <<<"));
+
+ title = strreplacei(title, ":", "%colon%"); // assume a title has the form "a?b:c",
+ // we need to replace the colon to avoid misinterpretation of the expression as a condition
+ buffer = strreplacei(buffer, "%title%", title);
+ free(title);
+
+ if (channel) {
+ char szChannelNr[6] = "";
+ snprintf(szChannelNr, 6, "%d", channel->Number());
+ buffer = strreplacei(buffer, "%chnr%", szChannelNr);
+ buffer = strreplacei(buffer, "%chsh%", channel->ShortName(true));
+ buffer = strreplacei(buffer, "%chlng%", channel->Name());
+ buffer = strreplacei(buffer, "%progr%", szProgressPart);
+ buffer = strreplacei(buffer, "%progrT2S%", szProgressPartT2S);
+ }
+
+ // parse the epxression and evaluate it
+ cVarExpr varExpr(buffer);
+ char* tmp = strdup(varExpr.Evaluate(event).c_str());
+ free(buffer);
+ buffer = tmp;
+
+ buffer = strreplacei(buffer, "$status$", szStatus);
+ buffer = strreplacei(buffer, "$t_status$", t);
+ buffer = strreplacei(buffer, "$v_status$", v);
+ buffer = strreplacei(buffer, "$r_status$", r);
+
+ buffer = FixSeparators(buffer, '~');
+ buffer = FixSeparators(buffer, ':');
+ buffer = FixSeparators(buffer, '-');
+
+ SetText(buffer, false);
+
+ if (gl_InfoConflict == 0 && EPGSearchConfig.checkTimerConflAfterTimerProg && !Force && timer && ((timerMatch && timerMatch != OldTimerMatch) || (isRemote != OldIsRemote))) {
+ cConflictCheck C;
+ C.Check();
+ if (C.TimerInConflict(timer))
+ gl_InfoConflict = 1;
+ }
+ return true;
+ }
+ return result;
}
void cMenuMyScheduleItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable)
{
- bool withDate = (channel == NULL); // search for a better way to determine this
- if (!DisplayMenu->SetItemEvent(event, Index, Current, Selectable, channel, withDate, timerMatch))
- DisplayMenu->SetItem(Text(), Index, Current, Selectable);
+ bool withDate = (channel == NULL); // search for a better way to determine this
+ if (!DisplayMenu->SetItemEvent(event, Index, Current, Selectable, channel, withDate, timerMatch))
+ DisplayMenu->SetItem(Text(), Index, Current, Selectable);
}
// --- cMenuMyScheduleSepItem ------------------------------------------------------
cMenuMyScheduleSepItem::cMenuMyScheduleSepItem(const cTimers *Timers, const cEvent *Event, const cChannel *Channel)
- : cMenuMyScheduleItem(Timers, Event, Channel, showNow, NULL)
+ : cMenuMyScheduleItem(Timers, Event, Channel, showNow, NULL)
{
- event = Event;
- channel = Channel;
- dummyEvent = NULL;
- SetSelectable(false);
- Update(Timers, true);
+ event = Event;
+ channel = Channel;
+ dummyEvent = NULL;
+ SetSelectable(false);
+ Update(Timers, true);
}
cMenuMyScheduleSepItem::~cMenuMyScheduleSepItem()
{
- if (dummyEvent)
- delete dummyEvent;
+ if (dummyEvent)
+ delete dummyEvent;
}
bool cMenuMyScheduleSepItem::Update(const cTimers *Timers, bool Force)
{
- if (channel)
- SetText(cString::sprintf("%s\t %s %s", MENU_SEPARATOR_ITEMS, channel->Name(), MENU_SEPARATOR_ITEMS));
- else if (event)
- {
- dummyEvent = new cEvent(0);
- dummyEvent->SetTitle(cString::sprintf("%s\t %s %s", MENU_SEPARATOR_ITEMS, GETDATESTRING(event), MENU_SEPARATOR_ITEMS));
- SetText(dummyEvent->Title());
+ if (channel)
+ SetText(cString::sprintf("%s\t %s %s", MENU_SEPARATOR_ITEMS, channel->Name(), MENU_SEPARATOR_ITEMS));
+ else if (event) {
+ dummyEvent = new cEvent(0);
+ dummyEvent->SetTitle(cString::sprintf("%s\t %s %s", MENU_SEPARATOR_ITEMS, GETDATESTRING(event), MENU_SEPARATOR_ITEMS));
+ SetText(dummyEvent->Title());
}
- return true;
+ return true;
}
void cMenuMyScheduleSepItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable)
{
- bool withDate = (channel == NULL); // search for a better way to determine this
- if (!DisplayMenu->SetItemEvent(dummyEvent, Index, Current, Selectable, channel, withDate, timerMatch))
- DisplayMenu->SetItem(Text(), Index, Current, Selectable);
+ bool withDate = (channel == NULL); // search for a better way to determine this
+ if (!DisplayMenu->SetItemEvent(dummyEvent, Index, Current, Selectable, channel, withDate, timerMatch))
+ DisplayMenu->SetItem(Text(), Index, Current, Selectable);
}
@@ -310,25 +287,25 @@ time_t cMenuWhatsOnSearch::seekTime = 0;
int cMenuWhatsOnSearch::shiftTime = 0;
cMenuWhatsOnSearch::cMenuWhatsOnSearch(int CurrentChannelNr)
-:cOsdMenu("", GetTab(1), GetTab(2), GetTab(3), GetTab(4), GetTab(5))
+ : cOsdMenu("", GetTab(1), GetTab(2), GetTab(3), GetTab(4), GetTab(5))
{
- if (currentShowMode == showNow)
- SetMenuCategory(mcScheduleNow);
- else if (currentShowMode == showNext)
- SetMenuCategory(mcScheduleNext);
- else
- SetMenuCategory(mcSchedule);
+ if (currentShowMode == showNow)
+ SetMenuCategory(mcScheduleNow);
+ else if (currentShowMode == showNext)
+ SetMenuCategory(mcScheduleNext);
+ else
+ SetMenuCategory(mcSchedule);
- helpKeys = -1;
- shiftTime = 0;
+ helpKeys = -1;
+ shiftTime = 0;
- CreateShowModes();
+ CreateShowModes();
- LoadSchedules();
+ LoadSchedules();
- currentChannel = CurrentChannelNr;
+ currentChannel = CurrentChannelNr;
- SetHelpKeys();
+ SetHelpKeys();
}
cMenuWhatsOnSearch::~cMenuWhatsOnSearch()
@@ -338,616 +315,560 @@ cMenuWhatsOnSearch::~cMenuWhatsOnSearch()
#ifdef USE_GRAPHTFT
const char* cMenuWhatsOnSearch::MenuKind()
{
- if (currentShowMode == showNow) return "MenuEpgsWhatsOnNow";
- if (currentShowMode == showNext) return "MenuEpgsWhatsOnNext";
- if (currentShowMode > showNext) return "MenuEpgsWhatsOnElse";
- else return "MenuWhatsOnElse";
+ if (currentShowMode == showNow) return "MenuEpgsWhatsOnNow";
+ if (currentShowMode == showNext) return "MenuEpgsWhatsOnNext";
+ if (currentShowMode > showNext) return "MenuEpgsWhatsOnElse";
+ else return "MenuWhatsOnElse";
}
void cMenuWhatsOnSearch::Display(void)
{
- cOsdMenu::Display();
+ cOsdMenu::Display();
- if (Count() > 0)
- {
- int i = 0;
+ if (Count() > 0) {
+ int i = 0;
- for (cOsdItem *item = First(); item; item = Next(item))
- cStatus::MsgOsdEventItem(!item->Selectable() ? 0 :
- ((cMenuMyScheduleItem*)item)->event,
- item->Text(), i++, Count());
- }
+ for (cOsdItem *item = First(); item; item = Next(item))
+ cStatus::MsgOsdEventItem(!item->Selectable() ? 0 :
+ ((cMenuMyScheduleItem*)item)->event,
+ item->Text(), i++, Count());
+ }
}
#endif /* GRAPHTFT */
int cMenuWhatsOnSearch::GetTab(int Tab)
{
- if (currentShowMode == showNow)
- return cTemplFile::GetTemplateByName("MenuWhatsOnNow")->Tab(Tab-1);
- if (currentShowMode == showNext)
- return cTemplFile::GetTemplateByName("MenuWhatsOnNext")->Tab(Tab-1);
- if (currentShowMode > showNext)
- return cTemplFile::GetTemplateByName("MenuWhatsOnElse")->Tab(Tab-1);
- else
- return 0;
+ if (currentShowMode == showNow)
+ return cTemplFile::GetTemplateByName("MenuWhatsOnNow")->Tab(Tab - 1);
+ if (currentShowMode == showNext)
+ return cTemplFile::GetTemplateByName("MenuWhatsOnNext")->Tab(Tab - 1);
+ if (currentShowMode > showNext)
+ return cTemplFile::GetTemplateByName("MenuWhatsOnElse")->Tab(Tab - 1);
+ else
+ return 0;
}
void cMenuWhatsOnSearch::LoadSchedules()
{
- Clear();
- eventObjects.Clear();
-
- // time_t SeekTime;
- cString szTitle;
- cShowMode* mode = GetShowMode(currentShowMode);
- if (!mode) return;
-
- if (shiftTime != 0)
- {
- if (currentShowMode == showNow || currentShowMode == showNext)
- seekTime = time(NULL);
- else
- {
- if (mode)
- seekTime = GetTimeT(mode->GetTime());
- if (seekTime < time(NULL)) seekTime += HOURS2SECS(24);
- }
- seekTime += shiftTime*60;
-
- struct tm tm_r;
- time_t now = time(NULL);
-
- tm tm_seek = *localtime_r(&seekTime, &tm_r);
- tm tm_now = *localtime_r(&now, &tm_r);
- if (tm_seek.tm_mday != tm_now.tm_mday)
- szTitle = cString::sprintf("%s - %s", tr("Overview"), DAYDATETIME(seekTime));
- else
- szTitle = cString::sprintf("%s - %02d:%02d", tr("Overview"), tm_seek.tm_hour, tm_seek.tm_min);
- }
- else
- {
- seekTime = GetTimeT(mode->GetTime());
- if (seekTime < time(NULL) && currentShowMode != showNow && currentShowMode != showNext)
- {
- seekTime += HOURS2SECS(24);
- szTitle = cString::sprintf("%s - %s (%s)", tr("Overview"), mode->GetDescription(), *WeekDayName(seekTime));
- }
- else
- szTitle = cString::sprintf("%s - %s", tr("Overview"), mode->GetDescription());
- }
- SetTitle(szTitle);
-
- cMenuTemplate* currentTemplate = NULL;
- if (currentShowMode == showNow)
- currentTemplate = cTemplFile::GetTemplateByName("MenuWhatsOnNow");
- if (currentShowMode == showNext)
- currentTemplate = cTemplFile::GetTemplateByName("MenuWhatsOnNext");
- if (currentShowMode > showNext)
- currentTemplate = cTemplFile::GetTemplateByName("MenuWhatsOnElse");
-
- int maxChannel = EPGSearchConfig.maxChannelMenuNow;
- if (currentChannel > maxChannel)
- maxChannel = 0;
-
- LOCK_TIMERS_READ; // needed in MyScheduleItem
- LOCK_CHANNELS_READ;
- for (const cChannel *Channel = Channels->First(); Channel; Channel = Channels->Next(Channel))
- {
- if (!Channel->GroupSep())
- {
- if (maxChannel && Channel->Number() > maxChannel) break;
- if (EPGSearchConfig.showRadioChannels == 0 && ISRADIO(Channel))
- continue;
-
- const cSchedule *Schedule;
- {
- LOCK_SCHEDULES_READ;
- Schedule = Schedules->GetSchedule(Channel);
- }
- const cEvent *Event = NULL;
- if (Schedule)
- {
- if (shiftTime != 0)
- Event = Schedule->GetEventAround(seekTime);
- else
+ Clear();
+ eventObjects.Clear();
+
+ // time_t SeekTime;
+ cString szTitle;
+ cShowMode* mode = GetShowMode(currentShowMode);
+ if (!mode) return;
+
+ if (shiftTime != 0) {
+ if (currentShowMode == showNow || currentShowMode == showNext)
+ seekTime = time(NULL);
+ else {
+ if (mode)
+ seekTime = GetTimeT(mode->GetTime());
+ if (seekTime < time(NULL)) seekTime += HOURS2SECS(24);
+ }
+ seekTime += shiftTime * 60;
+
+ struct tm tm_r;
+ time_t now = time(NULL);
+
+ tm tm_seek = *localtime_r(&seekTime, &tm_r);
+ tm tm_now = *localtime_r(&now, &tm_r);
+ if (tm_seek.tm_mday != tm_now.tm_mday)
+ szTitle = cString::sprintf("%s - %s", tr("Overview"), DAYDATETIME(seekTime));
+ else
+ szTitle = cString::sprintf("%s - %02d:%02d", tr("Overview"), tm_seek.tm_hour, tm_seek.tm_min);
+ } else {
+ seekTime = GetTimeT(mode->GetTime());
+ if (seekTime < time(NULL) && currentShowMode != showNow && currentShowMode != showNext) {
+ seekTime += HOURS2SECS(24);
+ szTitle = cString::sprintf("%s - %s (%s)", tr("Overview"), mode->GetDescription(), *WeekDayName(seekTime));
+ } else
+ szTitle = cString::sprintf("%s - %s", tr("Overview"), mode->GetDescription());
+ }
+ SetTitle(szTitle);
+
+ cMenuTemplate* currentTemplate = NULL;
+ if (currentShowMode == showNow)
+ currentTemplate = cTemplFile::GetTemplateByName("MenuWhatsOnNow");
+ if (currentShowMode == showNext)
+ currentTemplate = cTemplFile::GetTemplateByName("MenuWhatsOnNext");
+ if (currentShowMode > showNext)
+ currentTemplate = cTemplFile::GetTemplateByName("MenuWhatsOnElse");
+
+ int maxChannel = EPGSearchConfig.maxChannelMenuNow;
+ if (currentChannel > maxChannel)
+ maxChannel = 0;
+
+ LOCK_TIMERS_READ; // needed in MyScheduleItem
+ LOCK_CHANNELS_READ;
+ for (const cChannel *Channel = Channels->First(); Channel; Channel = Channels->Next(Channel)) {
+ if (!Channel->GroupSep()) {
+ if (maxChannel && Channel->Number() > maxChannel) break;
+ if (EPGSearchConfig.showRadioChannels == 0 && ISRADIO(Channel))
+ continue;
+
+ const cSchedule *Schedule;
{
- switch(currentShowMode)
- {
- default:
- case showNow:
- Event = Schedule->GetPresentEvent();
- break;
- case showNext:
- Event = Schedule->GetFollowingEvent();
- break;
- case showUserMode1:
- case showUserMode2:
- case showUserMode3:
- case showUserMode4:
- Event = Schedule->GetEventAround(seekTime);
- break;
- }
+ LOCK_SCHEDULES_READ;
+ Schedule = Schedules->GetSchedule(Channel);
}
- }
- if (!EPGSearchConfig.showEmptyChannels && !Event)
- continue;
-
- Add(new cMenuMyScheduleItem(Timers, Event, Channel, currentShowMode, currentTemplate), Channel->Number() == currentChannel);
- if (Event) eventObjects.Add(Event);
- }
- else
- {
- if (EPGSearchConfig.showChannelGroups && strlen(Channel->Name()))
- Add(new cMenuMyScheduleSepItem(NULL, NULL, Channel));
- }
- }
+ const cEvent *Event = NULL;
+ if (Schedule) {
+ if (shiftTime != 0)
+ Event = Schedule->GetEventAround(seekTime);
+ else {
+ switch (currentShowMode) {
+ default:
+ case showNow:
+ Event = Schedule->GetPresentEvent();
+ break;
+ case showNext:
+ Event = Schedule->GetFollowingEvent();
+ break;
+ case showUserMode1:
+ case showUserMode2:
+ case showUserMode3:
+ case showUserMode4:
+ Event = Schedule->GetEventAround(seekTime);
+ break;
+ }
+ }
+ }
+ if (!EPGSearchConfig.showEmptyChannels && !Event)
+ continue;
+
+ Add(new cMenuMyScheduleItem(Timers, Event, Channel, currentShowMode, currentTemplate), Channel->Number() == currentChannel);
+ if (Event) eventObjects.Add(Event);
+ } else {
+ if (EPGSearchConfig.showChannelGroups && strlen(Channel->Name()))
+ Add(new cMenuMyScheduleSepItem(NULL, NULL, Channel));
+ }
+ }
}
time_t cMenuWhatsOnSearch::GetTimeT(int iTime)
{
- struct tm tm_r;
- time_t t = time(NULL);
- tm* tmnow = localtime_r(&t, &tm_r);
- tmnow->tm_hour = HOURS(iTime);
- tmnow->tm_min = MINUTES(iTime);
- return mktime(tmnow);
+ struct tm tm_r;
+ time_t t = time(NULL);
+ tm* tmnow = localtime_r(&t, &tm_r);
+ tmnow->tm_hour = HOURS(iTime);
+ tmnow->tm_min = MINUTES(iTime);
+ return mktime(tmnow);
}
showMode cMenuWhatsOnSearch::GetNextMode()
{
- showMode nextShowMode = currentShowMode;
- cShowMode* Mode = GetShowMode(currentShowMode);
- if (Mode)
- {
- cShowMode* ModeNext = showModes.Next(Mode);
- if (ModeNext == NULL)
- nextShowMode = showNow;
- else
- nextShowMode = ModeNext->GetMode();
- }
- else // no mode found? fall back to 'now'
- nextShowMode = showNow;
- return nextShowMode;
+ showMode nextShowMode = currentShowMode;
+ cShowMode* Mode = GetShowMode(currentShowMode);
+ if (Mode) {
+ cShowMode* ModeNext = showModes.Next(Mode);
+ if (ModeNext == NULL)
+ nextShowMode = showNow;
+ else
+ nextShowMode = ModeNext->GetMode();
+ } else // no mode found? fall back to 'now'
+ nextShowMode = showNow;
+ return nextShowMode;
}
void cMenuWhatsOnSearch::CreateShowModes()
{
- showModes.Clear();
-
- cShowMode* ModeNow = new cShowMode(showNow, trVDR("Button$Now"));
- showModes.Add(ModeNow);
- cShowMode* ModeNext = new cShowMode(showNext, trVDR("Button$Next"));
- showModes.Add(ModeNext);
-
- time_t now = time(NULL);
- for(int i=showUserMode1; i<showModeMax; i++)
- {
- if (!EPGSearchConfig.ShowModes[i].GetUsage())
- continue;
-
- time_t SeekTime = GetTimeT(EPGSearchConfig.ShowModes[i].GetTime());
- if (SeekTime < now)
- SeekTime += HOURS2SECS(24);
- if (SeekTime - now > HOURS2SECS(SKIPHOURS))
- continue;
- cShowMode* Mode = new cShowMode((showMode)i, EPGSearchConfig.ShowModes[i].GetDescription(),
- 1, EPGSearchConfig.ShowModes[i].GetTime(), SeekTime);
- showModes.Add(Mode);
- }
- if (EPGSearchConfig.showFavoritesMenu)
- {
- cShowMode* ModeFav = new cShowMode(showFavorites, tr("Button$Favorites"));
- showModes.Add(ModeFav);
- }
- showModes.Sort();
+ showModes.Clear();
+
+ cShowMode* ModeNow = new cShowMode(showNow, trVDR("Button$Now"));
+ showModes.Add(ModeNow);
+ cShowMode* ModeNext = new cShowMode(showNext, trVDR("Button$Next"));
+ showModes.Add(ModeNext);
+
+ time_t now = time(NULL);
+ for (int i = showUserMode1; i < showModeMax; i++) {
+ if (!EPGSearchConfig.ShowModes[i].GetUsage())
+ continue;
+
+ time_t SeekTime = GetTimeT(EPGSearchConfig.ShowModes[i].GetTime());
+ if (SeekTime < now)
+ SeekTime += HOURS2SECS(24);
+ if (SeekTime - now > HOURS2SECS(SKIPHOURS))
+ continue;
+ cShowMode* Mode = new cShowMode((showMode)i, EPGSearchConfig.ShowModes[i].GetDescription(),
+ 1, EPGSearchConfig.ShowModes[i].GetTime(), SeekTime);
+ showModes.Add(Mode);
+ }
+ if (EPGSearchConfig.showFavoritesMenu) {
+ cShowMode* ModeFav = new cShowMode(showFavorites, tr("Button$Favorites"));
+ showModes.Add(ModeFav);
+ }
+ showModes.Sort();
}
cShowMode* cMenuWhatsOnSearch::GetShowMode(showMode mode)
{
- for (cShowMode *showMode = showModes.First(); showMode; showMode = showModes.Next(showMode))
- if (mode == showMode->GetMode())
- return showMode;
- return NULL;
+ for (cShowMode *showMode = showModes.First(); showMode; showMode = showModes.Next(showMode))
+ if (mode == showMode->GetMode())
+ return showMode;
+ return NULL;
}
const cChannel *cMenuWhatsOnSearch::ScheduleChannel(const cChannel *force_channel)
{
- const cChannel *ch = force_channel?force_channel:scheduleChannel;
- scheduleChannel = NULL;
- return ch;
+ const cChannel *ch = force_channel ? force_channel : scheduleChannel;
+ scheduleChannel = NULL;
+ return ch;
}
eOSState cMenuWhatsOnSearch::Switch(void)
{
- cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)Get(Current());
- if (item && item->channel) {
- if (cDevice::PrimaryDevice()->SwitchChannel(item->channel, true))
- return osEnd;
- }
- INFO(trVDR("Can't switch channel!"));
- return osContinue;
+ cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)Get(Current());
+ if (item && item->channel) {
+ if (cDevice::PrimaryDevice()->SwitchChannel(item->channel, true))
+ return osEnd;
+ }
+ INFO(trVDR("Can't switch channel!"));
+ return osContinue;
}
eOSState cMenuWhatsOnSearch::Record(void)
{
- cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)Get(Current());
- if (item)
- {
- LOCK_TIMERS_WRITE;
- Timers->SetExplicitModify();
- if (item->timerMatch == tmFull)
- {
- eTimerMatch tm = tmNone;
- cTimer *timer = Timers->GetMatch(item->event, &tm);
- if (timer)
- {
- if (EPGSearchConfig.useVDRTimerEditMenu)
- return AddSubMenu(new cMenuEditTimer(timer));
- else
- return AddSubMenu(new cMenuMyEditTimer(timer, false, item->event, item->channel));
- }
- }
-
- cTimer *timer = NULL;
- if (item->event)
- {
- timer = new cTimer(item->event);
- PrepareTimerFile(item->event, timer);
- }
- else
- timer = new cTimer(false, false, item->channel);
-
- cTimer *t = Timers->GetTimer(timer);
- if (EPGSearchConfig.onePressTimerCreation == 0 || t || !item->event || (!t && item->event && item->event->StartTime() - (Setup.MarginStart+2) * 60 < time(NULL)))
- {
- if (t)
- {
- delete timer;
- timer = t;
- }
- timer->SetFlags(tfActive);
- if (EPGSearchConfig.useVDRTimerEditMenu)
- return AddSubMenu(new cMenuEditTimer(timer, !t));
- else
- return AddSubMenu(new cMenuMyEditTimer(timer, !t, item->event, item->channel));
- }
- else
- {
- string fullaux = "";
- string aux = "";
- if (item->event)
- {
- const cEvent* event = item->event;
- int bstart = event->StartTime() - timer->StartTime();
- int bstop = timer->StopTime() - event->EndTime();
- int checkmode = DefTimerCheckModes.GetMode(timer->Channel());
- aux = UpdateAuxValue(aux, "channel", NumToString(timer->Channel()->Number()) + " - " + CHANNELNAME(timer->Channel()));
- aux = UpdateAuxValue(aux, "update", checkmode);
- aux = UpdateAuxValue(aux, "eventid", event->EventID());
- aux = UpdateAuxValue(aux, "bstart", bstart);
- aux = UpdateAuxValue(aux, "bstop", bstop);
- fullaux = UpdateAuxValue(fullaux, "epgsearch", aux);
- }
+ cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)Get(Current());
+ if (item) {
+ LOCK_TIMERS_WRITE;
+ Timers->SetExplicitModify();
+ if (item->timerMatch == tmFull) {
+ eTimerMatch tm = tmNone;
+ cTimer *timer = Timers->GetMatch(item->event, &tm);
+ if (timer) {
+ if (EPGSearchConfig.useVDRTimerEditMenu)
+ return AddSubMenu(new cMenuEditTimer(timer));
+ else
+ return AddSubMenu(new cMenuMyEditTimer(timer, false, item->event, item->channel));
+ }
+ }
+
+ cTimer *timer = NULL;
+ if (item->event) {
+ timer = new cTimer(item->event);
+ PrepareTimerFile(item->event, timer);
+ } else
+ timer = new cTimer(false, false, item->channel);
+
+ cTimer *t = Timers->GetTimer(timer);
+ if (EPGSearchConfig.onePressTimerCreation == 0 || t || !item->event || (!t && item->event && item->event->StartTime() - (Setup.MarginStart + 2) * 60 < time(NULL))) {
+ if (t) {
+ delete timer;
+ timer = t;
+ }
+ timer->SetFlags(tfActive);
+ if (EPGSearchConfig.useVDRTimerEditMenu)
+ return AddSubMenu(new cMenuEditTimer(timer, !t));
+ else
+ return AddSubMenu(new cMenuMyEditTimer(timer, !t, item->event, item->channel));
+ } else {
+ string fullaux = "";
+ string aux = "";
+ if (item->event) {
+ const cEvent* event = item->event;
+ int bstart = event->StartTime() - timer->StartTime();
+ int bstop = timer->StopTime() - event->EndTime();
+ int checkmode = DefTimerCheckModes.GetMode(timer->Channel());
+ aux = UpdateAuxValue(aux, "channel", NumToString(timer->Channel()->Number()) + " - " + CHANNELNAME(timer->Channel()));
+ aux = UpdateAuxValue(aux, "update", checkmode);
+ aux = UpdateAuxValue(aux, "eventid", event->EventID());
+ aux = UpdateAuxValue(aux, "bstart", bstart);
+ aux = UpdateAuxValue(aux, "bstop", bstop);
+ fullaux = UpdateAuxValue(fullaux, "epgsearch", aux);
+ }
#ifdef USE_PINPLUGIN
- aux = "";
- aux = UpdateAuxValue(aux, "protected", timer->FskProtection() ? "yes" : "no");
- fullaux = UpdateAuxValue(fullaux, "pin-plugin", aux);
+ aux = "";
+ aux = UpdateAuxValue(aux, "protected", timer->FskProtection() ? "yes" : "no");
+ fullaux = UpdateAuxValue(fullaux, "pin-plugin", aux);
#endif
- SetAux(timer, fullaux);
- if (Setup.SVDRPPeering && *Setup.SVDRPDefaultHost)
- timer->SetRemote(Setup.SVDRPDefaultHost);
- Timers->Add(timer);
- if (!HandleRemoteTimerModifications(timer)) {
- Timers->Del(timer);
- ERROR(tr("Epgsearch: RemoteTimerModifications failed"));
- }
- else {
- gl_timerStatusMonitor->SetConflictCheckAdvised();
- timer->Matches();
- Timers->SetModified();
- LogFile.iSysLog("timer %s added (active)", *timer->ToDescr());
- }
-
- if (HasSubMenu())
- CloseSubMenu();
- if (Update())
- Display();
- SetHelpKeys();
- }
- }
- return osContinue;
+ SetAux(timer, fullaux);
+ if (Setup.SVDRPPeering && *Setup.SVDRPDefaultHost)
+ timer->SetRemote(Setup.SVDRPDefaultHost);
+ Timers->Add(timer);
+ if (!HandleRemoteTimerModifications(timer)) {
+ Timers->Del(timer);
+ ERROR(tr("Epgsearch: RemoteTimerModifications failed"));
+ } else {
+ gl_timerStatusMonitor->SetConflictCheckAdvised();
+ timer->Matches();
+ Timers->SetModified();
+ LogFile.iSysLog("timer %s added (active)", *timer->ToDescr());
+ }
+
+ if (HasSubMenu())
+ CloseSubMenu();
+ if (Update())
+ Display();
+ SetHelpKeys();
+ }
+ }
+ return osContinue;
}
bool cMenuWhatsOnSearch::Update(void)
{
- bool result = false;
- LOCK_TIMERS_READ;
- for (cOsdItem *item = First(); item; item = Next(item)) {
- if (item->Selectable() && ((cMenuMyScheduleItem *)item)->Update(Timers))
- result = true;
- }
- return result;
+ bool result = false;
+ LOCK_TIMERS_READ;
+ for (cOsdItem *item = First(); item; item = Next(item)) {
+ if (item->Selectable() && ((cMenuMyScheduleItem *)item)->Update(Timers))
+ result = true;
+ }
+ return result;
}
eOSState cMenuWhatsOnSearch::Commands(eKeys Key)
{
- if (HasSubMenu() || Count() == 0)
- return osContinue;
-
- cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
- if (mi)
- {
- if (!mi->event)
- {
- if (Key == k3)
- return Switch();
- else if (Key == k2)
- return Record();
- else
- return osContinue;
- }
- cMenuSearchCommands *menu;
- eOSState state = AddSubMenu(menu = new cMenuSearchCommands(tr("EPG Commands"), mi->event, true));
- if (Key != kNone)
- state = menu->ProcessKey(Key);
- return state;
- }
- return osContinue;
+ if (HasSubMenu() || Count() == 0)
+ return osContinue;
+
+ cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
+ if (mi) {
+ if (!mi->event) {
+ if (Key == k3)
+ return Switch();
+ else if (Key == k2)
+ return Record();
+ else
+ return osContinue;
+ }
+ cMenuSearchCommands *menu;
+ eOSState state = AddSubMenu(menu = new cMenuSearchCommands(tr("EPG Commands"), mi->event, true));
+ if (Key != kNone)
+ state = menu->ProcessKey(Key);
+ return state;
+ }
+ return osContinue;
}
eOSState cMenuWhatsOnSearch::ExtendedSearch(void)
{
- return AddSubMenu(new cMenuEPGSearchExt());
+ return AddSubMenu(new cMenuEPGSearchExt());
}
void cMenuWhatsOnSearch::SetHelpKeys(bool Force)
{
- cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)Get(Current());
- int NewHelpKeys = 0;
- if (item) {
- if (item->Selectable() && item->timerMatch == tmFull)
- NewHelpKeys = 2;
- else
- NewHelpKeys = 1;
- }
-
- bool hasTimer = (NewHelpKeys == 2);
- if (NewHelpKeys != helpKeys || Force)
- {
- showMode nextShowMode = GetNextMode();
- cShowMode* mode = GetShowMode(nextShowMode);
- const char* szButtonGreen = NULL;
- if (mode)
- szButtonGreen = mode->GetDescription();
- if (toggleKeys==0)
- SetHelp((EPGSearchConfig.redkeymode==0?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")),
- szButtonGreen,
- trVDR("Button$Schedule"),
- EPGSearchConfig.bluekeymode==0?(EPGSearchConfig.useOkForSwitch?trVDR("Button$Info"):trVDR("Button$Switch")):tr("Button$Search"));
- else
- SetHelp((EPGSearchConfig.redkeymode==1?(hasTimer?trVDR("Button$Timer"):trVDR("Button$Record")):tr("Button$Commands")),
- (EPGSearchConfig.toggleGreenYellow==0?szButtonGreen:"<<"),
- (EPGSearchConfig.toggleGreenYellow==0?trVDR("Button$Schedule"):">>"),
- EPGSearchConfig.bluekeymode==1?(EPGSearchConfig.useOkForSwitch?trVDR("Button$Info"):trVDR("Button$Switch")):tr("Button$Search"));
- helpKeys = NewHelpKeys;
+ cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)Get(Current());
+ int NewHelpKeys = 0;
+ if (item) {
+ if (item->Selectable() && item->timerMatch == tmFull)
+ NewHelpKeys = 2;
+ else
+ NewHelpKeys = 1;
+ }
+
+ bool hasTimer = (NewHelpKeys == 2);
+ if (NewHelpKeys != helpKeys || Force) {
+ showMode nextShowMode = GetNextMode();
+ cShowMode* mode = GetShowMode(nextShowMode);
+ const char* szButtonGreen = NULL;
+ if (mode)
+ szButtonGreen = mode->GetDescription();
+ if (toggleKeys == 0)
+ SetHelp((EPGSearchConfig.redkeymode == 0 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")),
+ szButtonGreen,
+ trVDR("Button$Schedule"),
+ EPGSearchConfig.bluekeymode == 0 ? (EPGSearchConfig.useOkForSwitch ? trVDR("Button$Info") : trVDR("Button$Switch")) : tr("Button$Search"));
+ else
+ SetHelp((EPGSearchConfig.redkeymode == 1 ? (hasTimer ? trVDR("Button$Timer") : trVDR("Button$Record")) : tr("Button$Commands")),
+ (EPGSearchConfig.toggleGreenYellow == 0 ? szButtonGreen : "<<"),
+ (EPGSearchConfig.toggleGreenYellow == 0 ? trVDR("Button$Schedule") : ">>"),
+ EPGSearchConfig.bluekeymode == 1 ? (EPGSearchConfig.useOkForSwitch ? trVDR("Button$Info") : trVDR("Button$Switch")) : tr("Button$Search"));
+ helpKeys = NewHelpKeys;
}
}
eOSState cMenuWhatsOnSearch::Shift(int iMinutes)
{
- shiftTime += iMinutes;
- cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
- int TempChannel = currentChannel;
- if (mi)
- {
- currentChannel = mi->channel->Number();
- LOCK_CHANNELS_READ;
- scheduleChannel = Channels->GetByNumber(currentChannel);
- }
- LoadSchedules();
- Display();
- currentChannel = TempChannel;
- SetHelpKeys();
- return osContinue;
+ shiftTime += iMinutes;
+ cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
+ int TempChannel = currentChannel;
+ if (mi) {
+ currentChannel = mi->channel->Number();
+ LOCK_CHANNELS_READ;
+ scheduleChannel = Channels->GetByNumber(currentChannel);
+ }
+ LoadSchedules();
+ Display();
+ currentChannel = TempChannel;
+ SetHelpKeys();
+ return osContinue;
}
eOSState cMenuWhatsOnSearch::ShowSummary()
{
- if (Count())
- {
- const cEvent *ei = ((cMenuMyScheduleItem *)Get(Current()))->event;
- if (ei)
- {
- const cChannel *channel;
- {
- LOCK_CHANNELS_READ;
- channel = Channels->GetByChannelID(ei->ChannelID(), true, true);
- }
- if (channel)
- return AddSubMenu(new cMenuEventSearch(ei, eventObjects, SurfModeChannel));
- }
- }
- return osContinue;
+ if (Count()) {
+ const cEvent *ei = ((cMenuMyScheduleItem *)Get(Current()))->event;
+ if (ei) {
+ const cChannel *channel;
+ {
+ LOCK_CHANNELS_READ;
+ channel = Channels->GetByChannelID(ei->ChannelID(), true, true);
+ }
+ if (channel)
+ return AddSubMenu(new cMenuEventSearch(ei, eventObjects, SurfModeChannel));
+ }
+ }
+ return osContinue;
}
void cMenuWhatsOnSearch::UpdateCurrent()
{
- // navigation in summary could have changed current item, so update it
- cEventObj* cureventObj = eventObjects.GetCurrent();
- if (cureventObj && cureventObj->Event())
- for (cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)First(); item; item = (cMenuMyScheduleItem *)Next(item))
- if (item->Selectable() && item->event == cureventObj->Event())
- {
- cureventObj->Select(false);
- SetCurrent(item);
- Display();
- break;
- }
+ // navigation in summary could have changed current item, so update it
+ cEventObj* cureventObj = eventObjects.GetCurrent();
+ if (cureventObj && cureventObj->Event())
+ for (cMenuMyScheduleItem *item = (cMenuMyScheduleItem *)First(); item; item = (cMenuMyScheduleItem *)Next(item))
+ if (item->Selectable() && item->event == cureventObj->Event()) {
+ cureventObj->Select(false);
+ SetCurrent(item);
+ Display();
+ break;
+ }
}
eOSState cMenuWhatsOnSearch::ProcessKey(eKeys Key)
{
- exitToMainMenu = 0;
- if (!HasSubMenu() && Key == kBack)
- {
- exitToMainMenu = 1;
- return osBack;
- }
-
- bool HadSubMenu = HasSubMenu();
- eOSState state = cOsdMenu::ProcessKey(Key);
-
- if (!HasSubMenu() && HadSubMenu) // navigation in summary could have changed current item, so update it
- UpdateCurrent();
-
- if (state == osUnknown) {
- switch (Key) {
- case kFastRew:
- if(!HasSubMenu())
- return Shift(-EPGSearchConfig.timeShiftValue);
+ exitToMainMenu = 0;
+ if (!HasSubMenu() && Key == kBack) {
+ exitToMainMenu = 1;
+ return osBack;
+ }
+
+ bool HadSubMenu = HasSubMenu();
+ eOSState state = cOsdMenu::ProcessKey(Key);
+
+ if (!HasSubMenu() && HadSubMenu) // navigation in summary could have changed current item, so update it
+ UpdateCurrent();
+
+ if (state == osUnknown) {
+ switch (Key) {
+ case kFastRew:
+ if (!HasSubMenu())
+ return Shift(-EPGSearchConfig.timeShiftValue);
break;
- case kFastFwd:
- if(!HasSubMenu())
- return Shift(EPGSearchConfig.timeShiftValue);
+ case kFastFwd:
+ if (!HasSubMenu())
+ return Shift(EPGSearchConfig.timeShiftValue);
break;
- case kRecord:
- case kRed:
- if(HasSubMenu()) {
- UpdateCurrent();
- state = Record();
- break;
+ case kRecord:
+ case kRed:
+ if (HasSubMenu()) {
+ UpdateCurrent();
+ state = Record();
+ break;
}
- if (Count())
- {
- if (EPGSearchConfig.redkeymode==toggleKeys)
- state = Record();
- else
- {
- cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
- if (mi && mi->Selectable()) {
- if (mi->event)
- return AddSubMenu(new cMenuSearchCommands(tr("EPG Commands"),mi->event));
- else
- return osContinue;
- }
- }
+ if (Count()) {
+ if (EPGSearchConfig.redkeymode == toggleKeys)
+ state = Record();
+ else {
+ cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
+ if (mi && mi->Selectable()) {
+ if (mi->event)
+ return AddSubMenu(new cMenuSearchCommands(tr("EPG Commands"), mi->event));
+ else
+ return osContinue;
+ }
+ }
}
break;
- case k0:
- if(!HasSubMenu())
- {
- toggleKeys = 1 - toggleKeys;
- SetHelpKeys(true);
+ case k0:
+ if (!HasSubMenu()) {
+ toggleKeys = 1 - toggleKeys;
+ SetHelpKeys(true);
}
state = osContinue;
break;
- case k1...k9: return Commands(Key);
- case kYellow:
- if(!HasSubMenu())
- {
- if (toggleKeys == 0 || (toggleKeys == 1 && EPGSearchConfig.toggleGreenYellow == 0))
- {
- cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
- if (mi && mi->Selectable() && mi->channel)
- {
- LOCK_SCHEDULES_READ;
- const cSchedule *Schedule = Schedules->GetSchedule(mi->channel);
- if (Schedule)
- {
- time_t now = time(NULL);
- bool hasFutureEvents = false;
- for (const cEvent *e = Schedule->Events()->First(); e; e = Schedule->Events()->Next(e))
- if (e->StartTime() > now)
- {
- hasFutureEvents = true;
- break;
- }
- if (!hasFutureEvents)
- return osContinue;
- }
- else
- return osContinue;
- }
- state = osBack;
- // continue with kGreen
- }
- else
- return Shift(EPGSearchConfig.timeShiftValue);
+ case k1...k9:
+ return Commands(Key);
+ case kYellow:
+ if (!HasSubMenu()) {
+ if (toggleKeys == 0 || (toggleKeys == 1 && EPGSearchConfig.toggleGreenYellow == 0)) {
+ cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
+ if (mi && mi->Selectable() && mi->channel) {
+ LOCK_SCHEDULES_READ;
+ const cSchedule *Schedule = Schedules->GetSchedule(mi->channel);
+ if (Schedule) {
+ time_t now = time(NULL);
+ bool hasFutureEvents = false;
+ for (const cEvent *e = Schedule->Events()->First(); e; e = Schedule->Events()->Next(e))
+ if (e->StartTime() > now) {
+ hasFutureEvents = true;
+ break;
+ }
+ if (!hasFutureEvents)
+ return osContinue;
+ } else
+ return osContinue;
+ }
+ state = osBack;
+ // continue with kGreen
+ } else
+ return Shift(EPGSearchConfig.timeShiftValue);
}
- case kGreen:
- if(!HasSubMenu())
- {
- if (toggleKeys == 0 || (toggleKeys == 1 && EPGSearchConfig.toggleGreenYellow == 0))
- {
- if (Key == kYellow)
- currentShowMode = showNow;
- else
- currentShowMode = GetNextMode();
- cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
- if (mi && mi->Selectable())
- {
- currentChannel = mi->channel->Number();
- LOCK_CHANNELS_READ;
- scheduleChannel = Channels->GetByNumber(currentChannel);
- }
- }
- else
- return Shift(-EPGSearchConfig.timeShiftValue);
+ case kGreen:
+ if (!HasSubMenu()) {
+ if (toggleKeys == 0 || (toggleKeys == 1 && EPGSearchConfig.toggleGreenYellow == 0)) {
+ if (Key == kYellow)
+ currentShowMode = showNow;
+ else
+ currentShowMode = GetNextMode();
+ cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
+ if (mi && mi->Selectable()) {
+ currentChannel = mi->channel->Number();
+ LOCK_CHANNELS_READ;
+ scheduleChannel = Channels->GetByNumber(currentChannel);
+ }
+ } else
+ return Shift(-EPGSearchConfig.timeShiftValue);
}
break;
- case kBlue:
- if (HasSubMenu())
- {
- UpdateCurrent();
- return Switch();
+ case kBlue:
+ if (HasSubMenu()) {
+ UpdateCurrent();
+ return Switch();
}
- if (EPGSearchConfig.bluekeymode==toggleKeys)
- return EPGSearchConfig.useOkForSwitch?ShowSummary():Switch();
+ if (EPGSearchConfig.bluekeymode == toggleKeys)
+ return EPGSearchConfig.useOkForSwitch ? ShowSummary() : Switch();
else
- return ExtendedSearch();
+ return ExtendedSearch();
break;
- case kOk:
- {
+ case kOk: {
cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current());
- if (mi && mi->Selectable())
- {
- if (!mi->event) // no EPG, so simply switch to channel
- return Switch();
- else
- return EPGSearchConfig.useOkForSwitch?Switch():ShowSummary();
+ if (mi && mi->Selectable()) {
+ if (!mi->event) // no EPG, so simply switch to channel
+ return Switch();
+ else
+ return EPGSearchConfig.useOkForSwitch ? Switch() : ShowSummary();
+ }
+ }
+ break;
+ case kInfo:
+ return ShowSummary();
+ break;
+ default:
+ break;
+ }
+ }
+ if (!HasSubMenu()) {
+ if ((HadSubMenu || gl_TimerProgged) && Update()) {
+ if (gl_TimerProgged) { // when using epgsearch's timer edit menu, update is delayed because of SVDRP
+ gl_TimerProgged = 0;
+ SetHelpKeys();
}
- }
- break;
- case kInfo:
- return ShowSummary();
- break;
- default: break;
- }
- }
- if (!HasSubMenu())
- {
- if ((HadSubMenu || gl_TimerProgged) && Update())
- {
- if (gl_TimerProgged) // when using epgsearch's timer edit menu, update is delayed because of SVDRP
- {
- gl_TimerProgged = 0;
+ Display();
+ }
+ if (Key != kNone)
SetHelpKeys();
- }
- Display();
- }
- if (Key != kNone)
- SetHelpKeys();
- if (gl_InfoConflict)
- {
- gl_InfoConflict = 0;
- if (Interface->Confirm(tr("Timer conflict! Show?")))
- return AddSubMenu(new cMenuConflictCheck());
- }
- }
-
- return state;
+ if (gl_InfoConflict) {
+ gl_InfoConflict = 0;
+ if (Interface->Confirm(tr("Timer conflict! Show?")))
+ return AddSubMenu(new cMenuConflictCheck());
+ }
+ }
+
+ return state;
}
diff --git a/menu_whatson.h b/menu_whatson.h
index 803b4bb..b99f81f 100644
--- a/menu_whatson.h
+++ b/menu_whatson.h
@@ -30,72 +30,79 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "menu_event.h"
// --- cMenuMyScheduleItem ------------------------------------------------------
-class cMenuMyScheduleItem : public cOsdItem {
+class cMenuMyScheduleItem : public cOsdItem
+{
public:
- const cEvent *event;
- const cChannel *channel;
- showMode mode;
- eTimerMatch timerMatch;
- bool isRemote;
- bool inSwitchList;
- bool timerActive;
- cMenuTemplate* menuTemplate;
+ const cEvent *event;
+ const cChannel *channel;
+ showMode mode;
+ eTimerMatch timerMatch;
+ bool isRemote;
+ bool inSwitchList;
+ bool timerActive;
+ cMenuTemplate* menuTemplate;
- cMenuMyScheduleItem(const cTimers *Timers, const cEvent *Event, const cChannel *Channel = NULL, showMode ShowMode = showNow, cMenuTemplate* menuTemplate = NULL);
- virtual bool Update(const cTimers *Timers, bool Force = false);
- virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable);
+ cMenuMyScheduleItem(const cTimers *Timers, const cEvent *Event, const cChannel *Channel = NULL, showMode ShowMode = showNow, cMenuTemplate* menuTemplate = NULL);
+ virtual bool Update(const cTimers *Timers, bool Force = false);
+ virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable);
};
// --- cMenuMyScheduleSepItem ------------------------------------------------------
-class cMenuMyScheduleSepItem : public cMenuMyScheduleItem {
- cEvent *dummyEvent; // this event is used to store the text of the separator in its title
- // to pass it in SetMenuItem via the event argument. Would be nice
- // if VDR had a SetItemSeparator function for this
+class cMenuMyScheduleSepItem : public cMenuMyScheduleItem
+{
+ cEvent *dummyEvent; // this event is used to store the text of the separator in its title
+ // to pass it in SetMenuItem via the event argument. Would be nice
+ // if VDR had a SetItemSeparator function for this
public:
- cMenuMyScheduleSepItem(const cTimers *Timers = NULL, const cEvent *Event = NULL, const cChannel *Channel = NULL);
- ~cMenuMyScheduleSepItem();
- virtual bool Update(const cTimers *Timers = NULL,bool Force = false);
- virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable);
+ cMenuMyScheduleSepItem(const cTimers *Timers = NULL, const cEvent *Event = NULL, const cChannel *Channel = NULL);
+ ~cMenuMyScheduleSepItem();
+ virtual bool Update(const cTimers *Timers = NULL, bool Force = false);
+ virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable);
};
// --- cMenuWhatsOnSearch ----------------------------------------------------------
-class cMenuWhatsOnSearch : public cOsdMenu {
+class cMenuWhatsOnSearch : public cOsdMenu
+{
private:
- int helpKeys;
- eOSState Record(void);
- eOSState ExtendedSearch(void);
- static int currentChannel;
- cEventObjects eventObjects;
- public:
- static const cChannel *scheduleChannel;
- static cList<cShowMode> showModes;
- static showMode currentShowMode;
- static int shiftTime;
- static time_t seekTime;
- time_t GetTimeT(int iTime);
- static showMode GetNextMode();
- cMenuWhatsOnSearch(int CurrentChannelNr);
- ~cMenuWhatsOnSearch();
- void LoadSchedules();
- static int CurrentChannel(void) { return currentChannel; }
- static void SetCurrentChannel(int ChannelNr) { currentChannel = ChannelNr; }
- static const cChannel *ScheduleChannel(const cChannel* forceChannel = NULL);
- virtual eOSState ProcessKey(eKeys Key);
- virtual eOSState Switch(void);
- virtual eOSState Shift(int);
- virtual eOSState Commands(eKeys Key);
- virtual eOSState ShowSummary();
- void SetHelpKeys(bool Force = false);
- int GetTab(int Tab);
- bool Update(void);
- void CreateShowModes();
- static cShowMode* GetShowMode(showMode mode);
- void UpdateCurrent();
+ int helpKeys;
+ eOSState Record(void);
+ eOSState ExtendedSearch(void);
+ static int currentChannel;
+ cEventObjects eventObjects;
+public:
+ static const cChannel *scheduleChannel;
+ static cList<cShowMode> showModes;
+ static showMode currentShowMode;
+ static int shiftTime;
+ static time_t seekTime;
+ time_t GetTimeT(int iTime);
+ static showMode GetNextMode();
+ cMenuWhatsOnSearch(int CurrentChannelNr);
+ ~cMenuWhatsOnSearch();
+ void LoadSchedules();
+ static int CurrentChannel(void) {
+ return currentChannel;
+ }
+ static void SetCurrentChannel(int ChannelNr) {
+ currentChannel = ChannelNr;
+ }
+ static const cChannel *ScheduleChannel(const cChannel* forceChannel = NULL);
+ virtual eOSState ProcessKey(eKeys Key);
+ virtual eOSState Switch(void);
+ virtual eOSState Shift(int);
+ virtual eOSState Commands(eKeys Key);
+ virtual eOSState ShowSummary();
+ void SetHelpKeys(bool Force = false);
+ int GetTab(int Tab);
+ bool Update(void);
+ void CreateShowModes();
+ static cShowMode* GetShowMode(showMode mode);
+ void UpdateCurrent();
#ifdef USE_GRAPHTFT
- virtual const char* MenuKind();
- virtual void Display(void);
+ virtual const char* MenuKind();
+ virtual void Display(void);
#endif
};
diff --git a/noannounce.c b/noannounce.c
index 09cbb97..70d7745 100644
--- a/noannounce.c
+++ b/noannounce.c
@@ -39,24 +39,23 @@ cNoAnnounce::cNoAnnounce(void)
cNoAnnounce::cNoAnnounce(const cEvent* e, time_t NextAnnounce)
{
- title = shortText = "";
- startTime = 0;
- buffer = NULL;
- if (e)
- {
- if (e->Title()) title = e->Title();
- if (e->ShortText()) shortText = e->ShortText();
- channelID = e->ChannelID();
- startTime = e->StartTime();
- nextAnnounce = NextAnnounce;
- }
+ title = shortText = "";
+ startTime = 0;
+ buffer = NULL;
+ if (e) {
+ if (e->Title()) title = e->Title();
+ if (e->ShortText()) shortText = e->ShortText();
+ channelID = e->ChannelID();
+ startTime = e->StartTime();
+ nextAnnounce = NextAnnounce;
+ }
}
cNoAnnounce::~cNoAnnounce(void)
{
if (buffer) {
- free(buffer);
- buffer = NULL;
+ free(buffer);
+ buffer = NULL;
}
}
@@ -81,38 +80,42 @@ bool cNoAnnounce::Parse(const char *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: title = value;
- break;
- case 2: shortText = value;
- break;
- case 3: channelID = tChannelID::FromString(value);
- break;
- case 4: startTime = atol(value);
- break;
- case 5: nextAnnounce = atol(value);
- break;
- default:
- break;
- } //switch
- }
- parameter++;
- }
- if (*pos) 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:
+ title = value;
+ break;
+ case 2:
+ shortText = value;
+ break;
+ case 3:
+ channelID = tChannelID::FromString(value);
+ break;
+ case 4:
+ startTime = atol(value);
+ break;
+ case 5:
+ nextAnnounce = atol(value);
+ break;
+ default:
+ break;
+ } //switch
+ }
+ parameter++;
+ }
+ if (*pos) pos++;
} //while
title = ReplaceAll(title, "|", ":");
@@ -126,11 +129,11 @@ const char *cNoAnnounce::ToText(void) const
{
free(buffer);
msprintf(&buffer, "%s:%s:%s:%ld:%ld",
- ReplaceAll(title, ":", "|").c_str(),
- ReplaceAll(shortText, ":", "|").c_str(),
- *channelID.ToString(),
- startTime,
- nextAnnounce);
+ ReplaceAll(title, ":", "|").c_str(),
+ ReplaceAll(shortText, ":", "|").c_str(),
+ *channelID.ToString(),
+ startTime,
+ nextAnnounce);
return buffer;
}
@@ -142,41 +145,36 @@ bool cNoAnnounce::Save(FILE *f)
// -- cNoAnnounces -----------------------------------------------------------------
cNoAnnounce* cNoAnnounces::InList(const cEvent* e)
{
- cNoAnnounce noAnnounceTemp(e);
- cNoAnnounce* noAnnounce = First();
- while (noAnnounce)
- {
- if (*noAnnounce == noAnnounceTemp)
- {
- if (noAnnounce->nextAnnounce > 0 && noAnnounce->nextAnnounce < time(NULL))
- {
- Del(noAnnounce); // active again
- return NULL;
- }
- else
- return noAnnounce;
- }
- noAnnounce = Next(noAnnounce);
- }
- return NULL;
+ cNoAnnounce noAnnounceTemp(e);
+ cNoAnnounce* noAnnounce = First();
+ while (noAnnounce) {
+ if (*noAnnounce == noAnnounceTemp) {
+ if (noAnnounce->nextAnnounce > 0 && noAnnounce->nextAnnounce < time(NULL)) {
+ Del(noAnnounce); // active again
+ return NULL;
+ } else
+ return noAnnounce;
+ }
+ noAnnounce = Next(noAnnounce);
+ }
+ return NULL;
}
void cNoAnnounces::ClearOutdated(void)
{
// remove outdated items
cNoAnnounce* noAnnounce = First();
- while (noAnnounce)
- {
- cNoAnnounce* noAnnounceNext = Next(noAnnounce);
- if (noAnnounce->startTime < time(NULL))
- Del(noAnnounce);
- noAnnounce = noAnnounceNext;
+ while (noAnnounce) {
+ cNoAnnounce* noAnnounceNext = Next(noAnnounce);
+ if (noAnnounce->startTime < time(NULL))
+ Del(noAnnounce);
+ noAnnounce = noAnnounceNext;
}
}
void cNoAnnounces::UpdateNextAnnounce(const cEvent* e, time_t NextAnnounce)
{
- cNoAnnounce* noAnnounce = InList(e);
- if (noAnnounce)
- noAnnounce->nextAnnounce = NextAnnounce;
+ cNoAnnounce* noAnnounce = InList(e);
+ if (noAnnounce)
+ noAnnounce->nextAnnounce = NextAnnounce;
}
diff --git a/noannounce.h b/noannounce.h
index 60b5bac..7fab41d 100644
--- a/noannounce.h
+++ b/noannounce.h
@@ -31,7 +31,8 @@ using std::string;
// --- cNoAnnouce --------------------------------------------------------
// an event that should not be announced again
-class cNoAnnounce : public cListObject {
+class cNoAnnounce : public cListObject
+{
public:
string title; // Title of this event
string shortText; // Short description of this event
@@ -50,11 +51,14 @@ public:
bool Parse(const char *s);
const char *ToText(void) const;
bool Save(FILE *f);
- bool Valid() { return startTime > 0; }
+ bool Valid() {
+ return startTime > 0;
+ }
};
-class cNoAnnounces : public cConfig<cNoAnnounce> {
- public:
+class cNoAnnounces : public cConfig<cNoAnnounce>
+{
+public:
cNoAnnounce* InList(const cEvent* e);
void ClearOutdated(void);
void UpdateNextAnnounce(const cEvent* e, time_t NextAnnounce);
diff --git a/pending_notifications.c b/pending_notifications.c
index 2702d1f..9322e76 100644
--- a/pending_notifications.c
+++ b/pending_notifications.c
@@ -33,21 +33,23 @@ char *cPendingNotification::buffer = NULL;
cPendingNotification::~cPendingNotification(void)
{
if (buffer) {
- free(buffer);
- buffer = NULL;
+ free(buffer);
+ buffer = NULL;
}
}
bool cPendingNotification::Parse(const char *s)
{
char *t = skipspace(s + 1);
switch (*s) {
- case 'F': strreplace(t, '|', '\n');
- formatted = strdup(t);
- break;
- default: LogFile.eSysLog("ERROR: unexpected tag while reading epgsearch pending notifications data: %s", s);
- return false;
+ case 'F':
+ strreplace(t, '|', '\n');
+ formatted = strdup(t);
+ break;
+ default:
+ LogFile.eSysLog("ERROR: unexpected tag while reading epgsearch pending notifications data: %s", s);
+ return false;
}
- return true;
+ return true;
}
bool cPendingNotification::Read(FILE *f)
@@ -56,56 +58,54 @@ bool cPendingNotification::Read(FILE *f)
char *s;
cReadLine ReadLine;
while ((s = ReadLine.Read(f)) != NULL) {
- char *t = skipspace(s + 1);
- switch (*s) {
- case 'N': if (!p) {
- tEventID EventID;
- int Type, TimerMod, SearchID;
- time_t Start;
- int n = sscanf(t, "%d %u %d %d %ld", &Type, &EventID, &TimerMod, &SearchID, &Start);
- if (n == 5) {
- p = new cPendingNotification;
- if (p)
- {
- p->type = Type;
- p->eventID = EventID;
- p->timerMod = TimerMod;
- p->searchID = SearchID;
- p->start = Start;
-
- PendingNotifications.Add(p);
- }
- }
- }
- break;
- case 'C':
- {
- s = skipspace(s + 1);
- char *pC = strchr(s, ' ');
- if (pC)
- *pC = 0; // strips optional channel name
- if (*s) {
- tChannelID channelID = tChannelID::FromString(s);
- if (channelID.Valid()) {
- if (p)
- p->channelID = channelID;
- }
- else {
- LogFile.Log(3, "ERROR: illegal channel ID: %s", s);
- return false;
+ char *t = skipspace(s + 1);
+ switch (*s) {
+ case 'N':
+ if (!p) {
+ tEventID EventID;
+ int Type, TimerMod, SearchID;
+ time_t Start;
+ int n = sscanf(t, "%d %u %d %d %ld", &Type, &EventID, &TimerMod, &SearchID, &Start);
+ if (n == 5) {
+ p = new cPendingNotification;
+ if (p) {
+ p->type = Type;
+ p->eventID = EventID;
+ p->timerMod = TimerMod;
+ p->searchID = SearchID;
+ p->start = Start;
+
+ PendingNotifications.Add(p);
}
- }
- }
- break;
- case 'n':
- p = NULL;
- break;
- default: if (p && !p->Parse(s))
- {
- LogFile.Log(1,"ERROR: parsing %s", s);
- return false;
- }
- }
+ }
+ }
+ break;
+ case 'C': {
+ s = skipspace(s + 1);
+ char *pC = strchr(s, ' ');
+ if (pC)
+ *pC = 0; // strips optional channel name
+ if (*s) {
+ tChannelID channelID = tChannelID::FromString(s);
+ if (channelID.Valid()) {
+ if (p)
+ p->channelID = channelID;
+ } else {
+ LogFile.Log(3, "ERROR: illegal channel ID: %s", s);
+ return false;
+ }
+ }
+ }
+ break;
+ case 'n':
+ p = NULL;
+ break;
+ default:
+ if (p && !p->Parse(s)) {
+ LogFile.Log(1, "ERROR: parsing %s", s);
+ return false;
+ }
+ }
}
return true;
}
@@ -113,26 +113,26 @@ bool cPendingNotification::Read(FILE *f)
const char *cPendingNotification::ToText(void) const
{
- char* tmpFormatted = formatted!=""?strdup(formatted.c_str()):NULL;
+ char* tmpFormatted = formatted != "" ? strdup(formatted.c_str()) : NULL;
if (tmpFormatted)
- strreplace(tmpFormatted, '\n', '|');
+ strreplace(tmpFormatted, '\n', '|');
if (buffer)
- free(buffer);
+ free(buffer);
buffer = NULL;
LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByChannelID(channelID, true, true);
if (!channel)
- LogFile.Log(3,"invalid channel in pending notifications!");
+ LogFile.Log(3, "invalid channel in pending notifications!");
msprintf(&buffer, "N %d %u %d %d %ld\nC %s\n%s%s%sn",
- type, eventID, timerMod, searchID, start,
- channel?CHANNELSTRING(channel):"",
- tmpFormatted?"F ":"",tmpFormatted?tmpFormatted:"", tmpFormatted?"\n":"");
+ type, eventID, timerMod, searchID, start,
+ channel ? CHANNELSTRING(channel) : "",
+ tmpFormatted ? "F " : "", tmpFormatted ? tmpFormatted : "", tmpFormatted ? "\n" : "");
if (tmpFormatted)
- free(tmpFormatted);
+ free(tmpFormatted);
return buffer;
}
@@ -146,23 +146,23 @@ bool cPendingNotifications::Load(const char *FileName)
{
Clear();
if (FileName) {
- free(fileName);
- fileName = strdup(FileName);
+ free(fileName);
+ fileName = strdup(FileName);
}
if (fileName && access(fileName, F_OK) == 0) {
- LogFile.iSysLog("loading %s", fileName);
- FILE *f = fopen(fileName, "r");
- bool result = false;
- if (f) {
- result = cPendingNotification::Read(f);
- fclose(f);
- }
- if (result)
- LogFile.Log(2,"loaded pending notifications from %s (count: %d)", fileName, Count());
- else
- LogFile.Log(1,"error loading pending notifications from %s (count: %d)", fileName, Count());
- return result;
+ LogFile.iSysLog("loading %s", fileName);
+ FILE *f = fopen(fileName, "r");
+ bool result = false;
+ if (f) {
+ result = cPendingNotification::Read(f);
+ fclose(f);
+ }
+ if (result)
+ LogFile.Log(2, "loaded pending notifications from %s (count: %d)", fileName, Count());
+ else
+ LogFile.Log(1, "error loading pending notifications from %s (count: %d)", fileName, Count());
+ return result;
}
return false;
}
@@ -173,19 +173,18 @@ bool cPendingNotifications::Save(void)
cPendingNotification* l = (cPendingNotification*)this->First();
cSafeFile f(fileName);
if (f.Open()) {
- while (l) {
- if (!l->Save(f)) {
+ while (l) {
+ if (!l->Save(f)) {
result = false;
break;
- }
- l = (cPendingNotification*)l->Next();
- }
- if (!f.Close())
- result = false;
- }
- else
- result = false;
- LogFile.Log(2,"saved pending notifications (count: %d)", Count());
+ }
+ l = (cPendingNotification*)l->Next();
+ }
+ if (!f.Close())
+ result = false;
+ } else
+ result = false;
+ LogFile.Log(2, "saved pending notifications (count: %d)", Count());
return result;
}
diff --git a/pending_notifications.h b/pending_notifications.h
index f86854e..c7c9301 100644
--- a/pending_notifications.h
+++ b/pending_notifications.h
@@ -29,45 +29,48 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
using std::string;
// --- cPendingNotification --------------------------------------------------------
-class cPendingNotification : public cListObject {
+class cPendingNotification : public cListObject
+{
public:
- int type;
- tEventID eventID;
- tChannelID channelID;
- time_t start;
- uint timerMod;
- int searchID;
- string formatted;
-
-
- static char *buffer;
-
- cPendingNotification()
- : type(-1), start(-1), timerMod(-1), searchID(-1) {}
- cPendingNotification(int Type, tEventID EventID, tChannelID ChannelID, time_t Start, uint TimerMod = -1,
- int SearchID = -1, string Formatted = "")
- : type(Type), eventID(EventID), channelID(ChannelID), start(Start), timerMod(TimerMod),
- searchID(SearchID), formatted(Formatted) {}
- ~cPendingNotification();
-
- static bool Read(FILE *f);
- bool Parse(const char *s);
- const char *ToText(void) const;
- bool Save(FILE *f);
+ int type;
+ tEventID eventID;
+ tChannelID channelID;
+ time_t start;
+ uint timerMod;
+ int searchID;
+ string formatted;
+
+
+ static char *buffer;
+
+ cPendingNotification()
+ : type(-1), start(-1), timerMod(-1), searchID(-1) {}
+ cPendingNotification(int Type, tEventID EventID, tChannelID ChannelID, time_t Start, uint TimerMod = -1,
+ int SearchID = -1, string Formatted = "")
+ : type(Type), eventID(EventID), channelID(ChannelID), start(Start), timerMod(TimerMod),
+ searchID(SearchID), formatted(Formatted) {}
+ ~cPendingNotification();
+
+ static bool Read(FILE *f);
+ bool Parse(const char *s);
+ const char *ToText(void) const;
+ bool Save(FILE *f);
};
-class cPendingNotifications : public cList<cPendingNotification> {
- public:
- private:
+class cPendingNotifications : public cList<cPendingNotification>
+{
+public:
+private:
char *fileName;
- public:
- cPendingNotifications() { fileName = NULL; }
- void Clear(void)
- {
- free(fileName);
- fileName = NULL;
- cList<cPendingNotification>::Clear();
- }
+public:
+ cPendingNotifications() {
+ fileName = NULL;
+ }
+ void Clear(void) {
+ free(fileName);
+ fileName = NULL;
+ cList<cPendingNotification>::Clear();
+ }
bool Load(const char *FileName = NULL);
bool Save(void);
};
diff --git a/quickepgsearch.c b/quickepgsearch.c
index 931e3fe..23f4ca1 100644
--- a/quickepgsearch.c
+++ b/quickepgsearch.c
@@ -34,15 +34,25 @@ static const char SETUPTEXT[] = trNOOP("Show in main menu");
class cPluginQuicksearch : 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-quicksearch-v1.0"); };
-
- protected:
- virtual const char* SetupText() { return I18nTranslate(SETUPTEXT, I18nEpgsearch); }
- virtual const char* MainMenuText() { return I18nTranslate(MAINMENUENTRY, I18nEpgsearch); }
+public:
+ virtual const char* Version() {
+ return VERSION;
+ }
+ virtual const char* Description() {
+ return I18nTranslate(DESCRIPTION, I18nEpgsearch);
+ }
+ virtual bool Initialize();
+ virtual cOsdObject* MainMenuAction() {
+ return GetEpgSearchMenu("Epgsearch-quicksearch-v1.0");
+ };
+
+protected:
+ virtual const char* SetupText() {
+ return I18nTranslate(SETUPTEXT, I18nEpgsearch);
+ }
+ virtual const char* MainMenuText() {
+ return I18nTranslate(MAINMENUENTRY, I18nEpgsearch);
+ }
};
bool cPluginQuicksearch::Initialize()
diff --git a/rcfile.c b/rcfile.c
index 12f3ae9..c577121 100644
--- a/rcfile.c
+++ b/rcfile.c
@@ -26,79 +26,74 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
cRCLine::cRCLine(void)
{
- name = value = NULL;
+ name = value = NULL;
}
cRCLine::cRCLine(const char *Name, const char *Value)
{
- name = strdup(Name);
- value = strdup(Value);
+ name = strdup(Name);
+ value = strdup(Value);
}
cRCLine::~cRCLine()
{
- free(name);
- free(value);
+ free(name);
+ free(value);
}
bool cRCLine::Parse(char *s)
{
- char *p = strchr(s, '=');
- if (p)
- {
- *p = 0;
- char *Name = compactspace(s);
- char *Value = compactspace(p + 1);
- if (*Name)
- {
- name = strdup(Name);
- value = strdup(Value);
- return true;
- }
- }
- return false;
+ char *p = strchr(s, '=');
+ if (p) {
+ *p = 0;
+ char *Name = compactspace(s);
+ char *Value = compactspace(p + 1);
+ if (*Name) {
+ name = strdup(Name);
+ value = strdup(Value);
+ return true;
+ }
+ }
+ return false;
}
cRCFile::cRCFile()
{
- ChannelNr = -1;
- SearchMode = 1; // default is 'AND'
- UseTitle = 1;
- UseSubtitle = 1;
- UseDescr = 1;
- strcpy(Search, "");
+ ChannelNr = -1;
+ SearchMode = 1; // default is 'AND'
+ UseTitle = 1;
+ UseSubtitle = 1;
+ UseDescr = 1;
+ strcpy(Search, "");
}
bool cRCFile::Load(const char *FileName)
{
- if (cConfig<cRCLine>::Load(FileName, true))
- {
- bool result = true;
- for (cRCLine *l = First(); l; l = Next(l))
- {
- bool error = false;
- if (!Parse(l->Name(), l->Value()))
- error = true;
- if (error)
- {
- LogFile.eSysLog("ERROR: unknown parameter: %s = %s", l->Name(), l->Value());
- result = false;
- }
- }
- return result;
- }
- return false;
+ if (cConfig<cRCLine>::Load(FileName, true)) {
+ bool result = true;
+ for (cRCLine *l = First(); l; l = Next(l)) {
+ bool error = false;
+ if (!Parse(l->Name(), l->Value()))
+ error = true;
+ if (error) {
+ LogFile.eSysLog("ERROR: unknown parameter: %s = %s", l->Name(), l->Value());
+ result = false;
+ }
+ }
+ return result;
+ }
+ return false;
}
bool cRCFile::Parse(const char *Name, const char *Value)
{
- if (!strcasecmp(Name, "Search")) strn0cpy(Search, Value, MAXSTRINGLEN);
- else if (!strcasecmp(Name, "SearchMode")) SearchMode = atoi(Value);
- else if (!strcasecmp(Name, "ChannelNr")) ChannelNr = atoi(Value);
- else if (!strcasecmp(Name, "UseTitle")) UseTitle = atoi(Value);
- else if (!strcasecmp(Name, "UseSubtitle")) UseSubtitle = atoi(Value);
- else if (!strcasecmp(Name, "UseDescr")) UseDescr = atoi(Value);
- else return false;
+ if (!strcasecmp(Name, "Search")) strn0cpy(Search, Value, MAXSTRINGLEN);
+ else if (!strcasecmp(Name, "SearchMode")) SearchMode = atoi(Value);
+ else if (!strcasecmp(Name, "ChannelNr")) ChannelNr = atoi(Value);
+ else if (!strcasecmp(Name, "UseTitle")) UseTitle = atoi(Value);
+ else if (!strcasecmp(Name, "UseSubtitle")) UseSubtitle = atoi(Value);
+ else if (!strcasecmp(Name, "UseDescr")) UseDescr = atoi(Value);
+ else return false;
- return true;
+ return true;
}
diff --git a/rcfile.h b/rcfile.h
index b10fd63..2bf5ed1 100644
--- a/rcfile.h
+++ b/rcfile.h
@@ -28,17 +28,22 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#define MAXSTRINGLEN 256
-class cRCLine : public cListObject {
+class cRCLine : public cListObject
+{
private:
- char *name;
- char *value;
+ char *name;
+ char *value;
public:
- cRCLine(void);
- cRCLine(const char *Name, const char *Value);
- virtual ~cRCLine();
- const char *Name(void) { return name; }
- const char *Value(void) { return value; }
- bool Parse(char *s);
+ cRCLine(void);
+ cRCLine(const char *Name, const char *Value);
+ virtual ~cRCLine();
+ const char *Name(void) {
+ return name;
+ }
+ const char *Value(void) {
+ return value;
+ }
+ bool Parse(char *s);
};
diff --git a/recdone.c b/recdone.c
index f40922d..d200df3 100644
--- a/recdone.c
+++ b/recdone.c
@@ -44,7 +44,7 @@ cRecDone::cRecDone()
startTime = 0;
duration = 0;
if (buffer)
- free(buffer);
+ free(buffer);
buffer = NULL;
searchID = -1;
rawdescription = NULL;
@@ -55,24 +55,22 @@ cRecDone::cRecDone(const cTimer* Timer, const cEvent* Event, cSearchExt* Search)
title = shortText = description = aux = rawdescription = NULL;
startTime = 0;
duration = 0;
- searchID = Search?Search->ID:-1;
+ searchID = Search ? Search->ID : -1;
buffer = NULL;
- if (Event)
- {
- if (Event->Title())
- title = strdup(Event->Title());
- if (Event->ShortText())
- shortText = strdup(Event->ShortText());
- if (Event->Description())
- description = strdup(Event->Description());
- startTime = Event->StartTime();
- duration = Event->Duration();
- if (Timer)
- {
- channelID = Timer->Channel()->GetChannelID();
- if (!isempty(Timer->Aux()))
- aux = strdup(Timer->Aux());
+ if (Event) {
+ if (Event->Title())
+ title = strdup(Event->Title());
+ if (Event->ShortText())
+ shortText = strdup(Event->ShortText());
+ if (Event->Description())
+ description = strdup(Event->Description());
+ startTime = Event->StartTime();
+ duration = Event->Duration();
+ if (Timer) {
+ channelID = Timer->Channel()->GetChannelID();
+ if (!isempty(Timer->Aux()))
+ aux = strdup(Timer->Aux());
} else {
channelID = tChannelID::InvalidID;
aux = NULL;
@@ -82,30 +80,30 @@ cRecDone::cRecDone(const cTimer* Timer, const cEvent* Event, cSearchExt* Search)
cRecDone::~cRecDone()
{
- if (buffer) {
- free(buffer);
- buffer = NULL;
- }
- if (title) {
- free(title);
- title = NULL;
- }
- if (shortText) {
- free(shortText);
- shortText = NULL;
- }
- if (description) {
- free(description);
- description = NULL;
- }
- if (rawdescription) {
- free(rawdescription);
- rawdescription = NULL;
- }
- if (aux) {
- free(aux);
- aux = NULL;
- }
+ if (buffer) {
+ free(buffer);
+ buffer = NULL;
+ }
+ if (title) {
+ free(title);
+ title = NULL;
+ }
+ if (shortText) {
+ free(shortText);
+ shortText = NULL;
+ }
+ if (description) {
+ free(description);
+ description = NULL;
+ }
+ if (rawdescription) {
+ free(rawdescription);
+ rawdescription = NULL;
+ }
+ if (aux) {
+ free(aux);
+ aux = NULL;
+ }
}
@@ -113,20 +111,25 @@ bool cRecDone::Parse(char *s)
{
char *t = skipspace(s + 1);
switch (*s) {
- case 'T': title = strdup(t);
- break;
- case 'S': shortText = strdup(t);
- break;
- case 'D': strreplace(t, '|', '\n');
- description = strdup(t);
- break;
- case '@': strreplace(t, '|', '\n');
- aux = strdup(t);
- break;
- default: LogFile.eSysLog("ERROR: unexpected tag while reading epgsearch done data: %s", s);
- return false;
+ case 'T':
+ title = strdup(t);
+ break;
+ case 'S':
+ shortText = strdup(t);
+ break;
+ case 'D':
+ strreplace(t, '|', '\n');
+ description = strdup(t);
+ break;
+ case '@':
+ strreplace(t, '|', '\n');
+ aux = strdup(t);
+ break;
+ default:
+ LogFile.eSysLog("ERROR: unexpected tag while reading epgsearch done data: %s", s);
+ return false;
}
- return true;
+ return true;
}
bool cRecDone::Read(FILE *f)
@@ -135,52 +138,50 @@ bool cRecDone::Read(FILE *f)
char *s;
cReadLine ReadLine;
while ((s = ReadLine.Read(f)) != NULL) {
- char *t = skipspace(s + 1);
- switch (*s) {
- case 'R': if (!recDone) {
- time_t StartTime;
- int Duration, SearchID;
- int n = sscanf(t, "%ld %d %d", &StartTime, &Duration, &SearchID);
- if (n == 3) {
- recDone = new cRecDone;
- if (recDone)
- {
- recDone->searchID = SearchID;
- recDone->startTime = StartTime;
- recDone->duration = Duration;
- RecsDone.Add(recDone);
- }
- }
- }
- break;
- case 'C':
- {
- s = skipspace(s + 1);
- char *p = strchr(s, ' ');
- if (p)
- *p = 0; // strips optional channel name
- if (*s) {
- tChannelID channelID = tChannelID::FromString(s);
- if (channelID.Valid()) {
- if (recDone)
- recDone->channelID = channelID;
+ char *t = skipspace(s + 1);
+ switch (*s) {
+ case 'R':
+ if (!recDone) {
+ time_t StartTime;
+ int Duration, SearchID;
+ int n = sscanf(t, "%ld %d %d", &StartTime, &Duration, &SearchID);
+ if (n == 3) {
+ recDone = new cRecDone;
+ if (recDone) {
+ recDone->searchID = SearchID;
+ recDone->startTime = StartTime;
+ recDone->duration = Duration;
+ RecsDone.Add(recDone);
}
- else {
- LogFile.Log(3, "ERROR: illegal channel ID: %s", s);
- return false;
- }
- }
- }
- break;
- case 'r':
- recDone = NULL;
- break;
- default: if (recDone && !recDone->Parse(s))
- {
- LogFile.Log(1,"ERROR: parsing %s", s);
- return false;
- }
- }
+ }
+ }
+ break;
+ case 'C': {
+ s = skipspace(s + 1);
+ char *p = strchr(s, ' ');
+ if (p)
+ *p = 0; // strips optional channel name
+ if (*s) {
+ tChannelID channelID = tChannelID::FromString(s);
+ if (channelID.Valid()) {
+ if (recDone)
+ recDone->channelID = channelID;
+ } else {
+ LogFile.Log(3, "ERROR: illegal channel ID: %s", s);
+ return false;
+ }
+ }
+ }
+ break;
+ case 'r':
+ recDone = NULL;
+ break;
+ default:
+ if (recDone && !recDone->Parse(s)) {
+ LogFile.Log(1, "ERROR: parsing %s", s);
+ return false;
+ }
+ }
}
return true;
}
@@ -188,35 +189,35 @@ bool cRecDone::Read(FILE *f)
const char *cRecDone::ToText(void)
{
- char* tmpDescr = description?strdup(description):NULL;
+ char* tmpDescr = description ? strdup(description) : NULL;
if (tmpDescr)
- strreplace(tmpDescr, '\n', '|');
+ strreplace(tmpDescr, '\n', '|');
- char* tmpInfo = aux?strdup(aux):NULL;
+ char* tmpInfo = aux ? strdup(aux) : NULL;
if (tmpInfo)
- strreplace(tmpInfo, '\n', '|');
+ strreplace(tmpInfo, '\n', '|');
if (buffer)
- free(buffer);
+ free(buffer);
buffer = NULL;
LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByChannelID(channelID, true, true);
if (!channel)
- LogFile.Log(3,"invalid channel in recs done!");
+ LogFile.Log(3, "invalid channel in recs done!");
msprintf(&buffer, "R %ld %d %d\nC %s\n%s%s%s%s%s%s%s%s%s%s%s%sr",
- startTime, duration, searchID,
- channel?CHANNELSTRING(channel):"",
- title?"T ":"",title?title:"", title?"\n":"",
- shortText?"S ":"",shortText?shortText:"", shortText?"\n":"",
- tmpDescr?"D ":"",tmpDescr?tmpDescr:"", tmpDescr?"\n":"",
- tmpInfo?"@ ":"",tmpInfo?tmpInfo:"", tmpInfo?"\n":"");
+ startTime, duration, searchID,
+ channel ? CHANNELSTRING(channel) : "",
+ title ? "T " : "", title ? title : "", title ? "\n" : "",
+ shortText ? "S " : "", shortText ? shortText : "", shortText ? "\n" : "",
+ tmpDescr ? "D " : "", tmpDescr ? tmpDescr : "", tmpDescr ? "\n" : "",
+ tmpInfo ? "@ " : "", tmpInfo ? tmpInfo : "", tmpInfo ? "\n" : "");
if (tmpDescr)
- free(tmpDescr);
+ free(tmpDescr);
if (tmpInfo)
- free(tmpInfo);
+ free(tmpInfo);
return buffer;
}
@@ -230,164 +231,151 @@ int cRecDone::ChannelNr()
LOCK_CHANNELS_READ;
const cChannel* channel = Channels->GetByChannelID(channelID, true, true);
if (!channel)
- return -1;
+ return -1;
else
- return channel->Number();
+ return channel->Number();
}
// -- cRecsDone -----------------------------------------------------------------
int cRecsDone::GetCountRecordings(const cEvent* event, cSearchExt* search, cRecDone** first, int matchLimit)
{
- return GetCountRecordings(event, search->compareTitle, search->compareSubtitle, search->compareSummary, search->compareDate, search->catvaluesAvoidRepeat, first, matchLimit);
+ return GetCountRecordings(event, search->compareTitle, search->compareSubtitle, search->compareSummary, search->compareDate, search->catvaluesAvoidRepeat, first, matchLimit);
}
bool CatValuesMatch(unsigned long catvaluesAvoidRepeat, const string& rDescr, const string& eDescr)
{
- bool bCatMatch = ((rDescr != "" && eDescr != "") || (rDescr == "" && eDescr == ""));
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (catvaluesAvoidRepeat > 0 && SearchExtCat && bCatMatch)
- {
- if (catvaluesAvoidRepeat & (1<<index))
- {
- char* eCatValue = GetExtEPGValue(eDescr.c_str(), SearchExtCat->name, SearchExtCat->format);
- char* rCatValue = GetExtEPGValue(rDescr.c_str(), SearchExtCat->name, SearchExtCat->format);
- if ((!eCatValue && rCatValue) ||
- (!rCatValue && eCatValue) ||
- (eCatValue && rCatValue && strcmp(eCatValue, rCatValue) != 0))
- bCatMatch = false;
- free(eCatValue);
- free(rCatValue);
- }
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
+ bool bCatMatch = ((rDescr != "" && eDescr != "") || (rDescr == "" && eDescr == ""));
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (catvaluesAvoidRepeat > 0 && SearchExtCat && bCatMatch) {
+ if (catvaluesAvoidRepeat & (1 << index)) {
+ char* eCatValue = GetExtEPGValue(eDescr.c_str(), SearchExtCat->name, SearchExtCat->format);
+ char* rCatValue = GetExtEPGValue(rDescr.c_str(), SearchExtCat->name, SearchExtCat->format);
+ if ((!eCatValue && rCatValue) ||
+ (!rCatValue && eCatValue) ||
+ (eCatValue && rCatValue && strcmp(eCatValue, rCatValue) != 0))
+ bCatMatch = false;
+ free(eCatValue);
+ free(rCatValue);
+ }
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
}
- return bCatMatch;
+ return bCatMatch;
}
bool MatchesInExpression(const string& expression, const cRecDone* recDone, const cEvent* event)
{
- cVarExpr varExpr(expression);
-
- cEvent recDoneEvent(0);
- recDoneEvent.SetTitle(recDone->title);
- recDoneEvent.SetShortText(recDone->shortText);
- recDoneEvent.SetDescription(recDone->description);
- recDoneEvent.SetStartTime(recDone->startTime);
- recDoneEvent.SetDuration(recDone->duration);
-
- string resRecDone = varExpr.Evaluate(&recDoneEvent);
- string resEvent = varExpr.Evaluate(event);
- return resRecDone == resEvent;
+ cVarExpr varExpr(expression);
+
+ cEvent recDoneEvent(0);
+ recDoneEvent.SetTitle(recDone->title);
+ recDoneEvent.SetShortText(recDone->shortText);
+ recDoneEvent.SetDescription(recDone->description);
+ recDoneEvent.SetStartTime(recDone->startTime);
+ recDoneEvent.SetDuration(recDone->duration);
+
+ string resRecDone = varExpr.Evaluate(&recDoneEvent);
+ string resEvent = varExpr.Evaluate(event);
+ return resRecDone == resEvent;
}
int cRecsDone::GetCountRecordings(const cEvent* event, bool compareTitle, int compareSubtitle, bool compareSummary, int compareDate, unsigned long catvaluesAvoidRepeat, cRecDone** first, int matchLimit)
{
- if (first)
- *first = NULL;
- if (!event)
- return 0;
-
- cMutexLock RecsDoneLock(this);
- int count = 0;
-
- string eTitle = "";
- if (compareTitle)
- {
- string s = event->Title()?event->Title():"";
- eTitle = GetAlNum(s);
- std::transform(eTitle.begin(), eTitle.end(), eTitle.begin(), tolower);
- }
- string eSubtitle = "";
- if (compareSubtitle)
- {
- string s = event->ShortText()?event->ShortText():"";
- eSubtitle = GetAlNum(s);
- std::transform(eSubtitle.begin(), eSubtitle.end(), eSubtitle.begin(), tolower);
- }
- string eDescr = "";
- string eRawDescr = "";
- if ((compareSummary || catvaluesAvoidRepeat != 0) && event->Description())
- {
- eDescr = event->Description();
- char* rawDescr = GetRawDescription(event->Description());
- eRawDescr = rawDescr?rawDescr:"";
- if (rawDescr) free(rawDescr);
- }
-
- string compareExpression = "";
- if (compareDate == 1) compareExpression = "%date%";
- if (compareDate == 2) compareExpression = "%year%-%week%";
- if (compareDate == 3) compareExpression = "%year%-%month%";
-
- cRecDone* firstrecDone = NULL;
- cRecDone* recDone = First();
- while (recDone)
- {
- string rTitle = "";
- if (compareTitle)
- {
- string s = recDone->title?recDone->title:"";
- rTitle = GetAlNum(s);
- std::transform(rTitle.begin(), rTitle.end(), rTitle.begin(), tolower);
- }
- string rSubtitle = "";
- if (compareSubtitle)
- {
- string s = recDone->shortText?recDone->shortText:"";
- rSubtitle = GetAlNum(s);
- std::transform(rSubtitle.begin(), rSubtitle.end(), rSubtitle.begin(), tolower);
- }
- string rDescr = "";
- string rRawDescr = "";
- if ((compareSummary || catvaluesAvoidRepeat != 0) && recDone->description)
- {
- rDescr = recDone->description;
- char* rawDescr = recDone->rawdescription?recDone->rawdescription:GetRawDescription(recDone->description);
- recDone->rawdescription = rawDescr;
- rRawDescr = rawDescr?rawDescr:"";
- }
-
- if ((!compareTitle || rTitle == eTitle) &&
- (!compareSubtitle || (rSubtitle == eSubtitle && rSubtitle !="")) &&
- (!compareSummary || DescriptionMatches(eRawDescr.c_str(), rRawDescr.c_str(), matchLimit)) &&
- (catvaluesAvoidRepeat == 0 || CatValuesMatch(catvaluesAvoidRepeat, rDescr, eDescr)) &&
- (compareExpression.size() == 0 || MatchesInExpression(compareExpression, recDone, event)))
- {
- if (!firstrecDone) firstrecDone = recDone;
- else
- if (firstrecDone->startTime > recDone->startTime)
- firstrecDone = recDone;
- LogFile.Log(3,"same event already recorded at %s", DAYDATETIME(recDone->startTime));
- count++;
- }
-
- recDone = Next(recDone);
- }
-
-
- if (first)
- *first = firstrecDone;
-
- return count;
+ if (first)
+ *first = NULL;
+ if (!event)
+ return 0;
+
+ cMutexLock RecsDoneLock(this);
+ int count = 0;
+
+ string eTitle = "";
+ if (compareTitle) {
+ string s = event->Title() ? event->Title() : "";
+ eTitle = GetAlNum(s);
+ std::transform(eTitle.begin(), eTitle.end(), eTitle.begin(), tolower);
+ }
+ string eSubtitle = "";
+ if (compareSubtitle) {
+ string s = event->ShortText() ? event->ShortText() : "";
+ eSubtitle = GetAlNum(s);
+ std::transform(eSubtitle.begin(), eSubtitle.end(), eSubtitle.begin(), tolower);
+ }
+ string eDescr = "";
+ string eRawDescr = "";
+ if ((compareSummary || catvaluesAvoidRepeat != 0) && event->Description()) {
+ eDescr = event->Description();
+ char* rawDescr = GetRawDescription(event->Description());
+ eRawDescr = rawDescr ? rawDescr : "";
+ if (rawDescr) free(rawDescr);
+ }
+
+ string compareExpression = "";
+ if (compareDate == 1) compareExpression = "%date%";
+ if (compareDate == 2) compareExpression = "%year%-%week%";
+ if (compareDate == 3) compareExpression = "%year%-%month%";
+
+ cRecDone* firstrecDone = NULL;
+ cRecDone* recDone = First();
+ while (recDone) {
+ string rTitle = "";
+ if (compareTitle) {
+ string s = recDone->title ? recDone->title : "";
+ rTitle = GetAlNum(s);
+ std::transform(rTitle.begin(), rTitle.end(), rTitle.begin(), tolower);
+ }
+ string rSubtitle = "";
+ if (compareSubtitle) {
+ string s = recDone->shortText ? recDone->shortText : "";
+ rSubtitle = GetAlNum(s);
+ std::transform(rSubtitle.begin(), rSubtitle.end(), rSubtitle.begin(), tolower);
+ }
+ string rDescr = "";
+ string rRawDescr = "";
+ if ((compareSummary || catvaluesAvoidRepeat != 0) && recDone->description) {
+ rDescr = recDone->description;
+ char* rawDescr = recDone->rawdescription ? recDone->rawdescription : GetRawDescription(recDone->description);
+ recDone->rawdescription = rawDescr;
+ rRawDescr = rawDescr ? rawDescr : "";
+ }
+
+ if ((!compareTitle || rTitle == eTitle) &&
+ (!compareSubtitle || (rSubtitle == eSubtitle && rSubtitle != "")) &&
+ (!compareSummary || DescriptionMatches(eRawDescr.c_str(), rRawDescr.c_str(), matchLimit)) &&
+ (catvaluesAvoidRepeat == 0 || CatValuesMatch(catvaluesAvoidRepeat, rDescr, eDescr)) &&
+ (compareExpression.size() == 0 || MatchesInExpression(compareExpression, recDone, event))) {
+ if (!firstrecDone) firstrecDone = recDone;
+ else if (firstrecDone->startTime > recDone->startTime)
+ firstrecDone = recDone;
+ LogFile.Log(3, "same event already recorded at %s", DAYDATETIME(recDone->startTime));
+ count++;
+ }
+
+ recDone = Next(recDone);
+ }
+
+
+ if (first)
+ *first = firstrecDone;
+
+ return count;
}
void cRecsDone::RemoveSearchID(int ID)
{
if (ID == -1)
- return;
+ return;
cMutexLock RecsDoneLock(this);
if (Count() == 0)
- Load(AddDirectory(CONFIGDIR, "epgsearchdone.data"));
+ Load(AddDirectory(CONFIGDIR, "epgsearchdone.data"));
cRecDone* recDone = First();
- while (recDone)
- {
- if (recDone->searchID == ID)
- {
- recDone->searchID = -1;
- LogFile.Log(2,"search timer %d removed in recording %s~%s", ID, recDone->title?recDone->title:"unknown title", recDone->shortText?recDone->shortText:"unknown subtitle");
- }
- recDone = Next(recDone);
+ while (recDone) {
+ if (recDone->searchID == ID) {
+ recDone->searchID = -1;
+ LogFile.Log(2, "search timer %d removed in recording %s~%s", ID, recDone->title ? recDone->title : "unknown title", recDone->shortText ? recDone->shortText : "unknown subtitle");
+ }
+ recDone = Next(recDone);
}
Save();
}
@@ -397,23 +385,23 @@ bool cRecsDone::Load(const char *FileName)
cMutexLock RecsDoneLock(this);
Clear();
if (FileName) {
- free(fileName);
- fileName = strdup(FileName);
+ free(fileName);
+ fileName = strdup(FileName);
}
if (fileName && access(fileName, F_OK) == 0) {
- LogFile.iSysLog("loading %s", fileName);
- FILE *f = fopen(fileName, "r");
- bool result = false;
- if (f) {
- result = cRecDone::Read(f);
- fclose(f);
- }
- if (result)
- LogFile.Log(2,"loaded recordings done from %s (count: %d)", fileName, Count());
- else
- LogFile.Log(1,"error loading recordings done from %s (count: %d)", fileName, Count());
- return result;
+ LogFile.iSysLog("loading %s", fileName);
+ FILE *f = fopen(fileName, "r");
+ bool result = false;
+ if (f) {
+ result = cRecDone::Read(f);
+ fclose(f);
+ }
+ if (result)
+ LogFile.Log(2, "loaded recordings done from %s (count: %d)", fileName, Count());
+ else
+ LogFile.Log(1, "error loading recordings done from %s (count: %d)", fileName, Count());
+ return result;
}
return false;
}
@@ -425,52 +413,48 @@ bool cRecsDone::Save(void)
cRecDone* l = (cRecDone*)this->First();
cSafeFile f(fileName);
if (f.Open()) {
- while (l) {
- if (!l->title) { // atleast a title should exist
- l = (cRecDone*)l->Next();
- continue;
- }
- if (!l->Save(f)) {
+ while (l) {
+ if (!l->title) { // atleast a title should exist
+ l = (cRecDone*)l->Next();
+ continue;
+ }
+ if (!l->Save(f)) {
result = false;
break;
- }
- l = (cRecDone*)l->Next();
- }
- if (!f.Close())
- result = false;
- }
- else
- result = false;
- LogFile.Log(2,"saved recordings done (count: %d)", Count());
+ }
+ l = (cRecDone*)l->Next();
+ }
+ if (!f.Close())
+ result = false;
+ } else
+ result = false;
+ LogFile.Log(2, "saved recordings done (count: %d)", Count());
return result;
}
int cRecsDone::GetTotalCountRecordings(cSearchExt* search, cRecDone** first)
{
- if (!search) return 0;
- if (first)
- *first = NULL;
-
- cMutexLock RecsDoneLock(this);
- int count = 0;
-
- cRecDone* firstrecDone = NULL;
- cRecDone* recDone = First();
- while (recDone)
- {
- if (recDone->searchID == search->ID)
- {
- count++;
- if (!firstrecDone) firstrecDone = recDone;
- else
- if (firstrecDone->startTime > recDone->startTime)
- firstrecDone = recDone;
- }
- recDone = Next(recDone);
- }
-
- if (first)
- *first = firstrecDone;
-
- return count;
+ if (!search) return 0;
+ if (first)
+ *first = NULL;
+
+ cMutexLock RecsDoneLock(this);
+ int count = 0;
+
+ cRecDone* firstrecDone = NULL;
+ cRecDone* recDone = First();
+ while (recDone) {
+ if (recDone->searchID == search->ID) {
+ count++;
+ if (!firstrecDone) firstrecDone = recDone;
+ else if (firstrecDone->startTime > recDone->startTime)
+ firstrecDone = recDone;
+ }
+ recDone = Next(recDone);
+ }
+
+ if (first)
+ *first = firstrecDone;
+
+ return count;
}
diff --git a/recdone.h b/recdone.h
index 3157305..cfad67f 100644
--- a/recdone.h
+++ b/recdone.h
@@ -32,7 +32,8 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
class cSearchExt;
// --- cRecDone --------------------------------------------------------
-class cRecDone : public cListObject {
+class cRecDone : public cListObject
+{
public:
char *title; // Title of this event
char *shortText; // Short description of this event
@@ -57,17 +58,19 @@ public:
int ChannelNr();
};
-class cRecsDone : public cList<cRecDone>, public cMutex {
- private:
+class cRecsDone : public cList<cRecDone>, public cMutex
+{
+private:
char *fileName;
- public:
- void Clear(void)
- {
- free(fileName);
- fileName = NULL;
- cList<cRecDone>::Clear();
- }
- cRecsDone(void) { fileName = NULL; }
+public:
+ void Clear(void) {
+ free(fileName);
+ fileName = NULL;
+ cList<cRecDone>::Clear();
+ }
+ cRecsDone(void) {
+ fileName = NULL;
+ }
int GetCountRecordings(const cEvent* event, cSearchExt* search, cRecDone** first = NULL, int matchLimit = 90);
int GetCountRecordings(const cEvent*, bool compareTitle, int compareSubtitle, bool compareSummary, int compareDate, unsigned long, cRecDone** first = NULL, int matchLimit = 90);
int GetTotalCountRecordings(cSearchExt* search, cRecDone** first);
diff --git a/recdone_thread.c b/recdone_thread.c
index 9e7b38b..6b0e02b 100644
--- a/recdone_thread.c
+++ b/recdone_thread.c
@@ -32,11 +32,12 @@ Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
extern int updateForced;
cRecdoneThread::cRecdoneThread()
-: cThread("EPGSearch: recdone")
+ : cThread("EPGSearch: recdone")
{
}
-cRecdoneThread::~cRecdoneThread() {
+cRecdoneThread::~cRecdoneThread()
+{
}
bool cRecdoneThread::IsPesRecording(const cRecording *pRecording)
@@ -47,16 +48,15 @@ bool cRecdoneThread::IsPesRecording(const cRecording *pRecording)
#define LOC_INDEXFILESUFFIX "/index"
struct tIndexTs {
- uint64_t offset:40; // up to 1TB per file (not using off_t here - must definitely be exactly 64 bit!)
- int reserved:7; // reserved for future use
- int independent:1; // marks frames that can be displayed by themselves (for trick modes)
- uint16_t number:16; // up to 64K files per recording
- tIndexTs(off_t Offset, bool Independent, uint16_t Number)
- {
- offset = Offset;
- reserved = 0;
- independent = Independent;
- number = Number;
+ uint64_t offset: 40; // up to 1TB per file (not using off_t here - must definitely be exactly 64 bit!)
+ int reserved: 7; // reserved for future use
+ int independent: 1; // marks frames that can be displayed by themselves (for trick modes)
+ uint16_t number: 16; // up to 64K files per recording
+ tIndexTs(off_t Offset, bool Independent, uint16_t Number) {
+ offset = Offset;
+ reserved = 0;
+ independent = Independent;
+ number = Number;
}
};
@@ -64,47 +64,41 @@ int cRecdoneThread::RecLengthInSecs(const cRecording *pRecording)
{
struct stat buf;
cString fullname = cString::sprintf("%s%s", pRecording->FileName(), IsPesRecording(pRecording) ? LOC_INDEXFILESUFFIX ".vdr" : LOC_INDEXFILESUFFIX);
- if (pRecording->FileName() && *fullname && access(fullname, R_OK) == 0 && stat(fullname, &buf) == 0)
- {
- double frames = buf.st_size ? (buf.st_size - 1) / sizeof(tIndexTs) + 1 : 0;
- double Seconds = 0;
- modf((frames + 0.5) / pRecording->FramesPerSecond(), &Seconds);
- return Seconds;
+ if (pRecording->FileName() && *fullname && access(fullname, R_OK) == 0 && stat(fullname, &buf) == 0) {
+ double frames = buf.st_size ? (buf.st_size - 1) / sizeof(tIndexTs) + 1 : 0;
+ double Seconds = 0;
+ modf((frames + 0.5) / pRecording->FramesPerSecond(), &Seconds);
+ return Seconds;
}
return -1;
}
void cRecdoneThread::Action(void)
{
- LogFile.Log(1,"started recdone_thread");
+ LogFile.Log(1, "started recdone_thread");
cMutexLock RecsDoneLock(&RecsDone);
time_t now = time(NULL);
// remove timers that finished recording from TimersRecording
// incomplete recordings are kept for a while, perhaps they will be resumed
LOCK_TIMERS_READ;
- while (m_fnames.size())
- {
- vector<string>::iterator it=m_fnames.begin();
- const char *m_filename=(*it).c_str();
- LogFile.Log(1,"recdone_thread processing %s",m_filename);
+ while (m_fnames.size()) {
+ vector<string>::iterator it = m_fnames.begin();
+ const char *m_filename = (*it).c_str();
+ LogFile.Log(1, "recdone_thread processing %s", m_filename);
cMutexLock TimersRecordingLock(&TimersRecording);
cRecDoneTimerObj *tiR = TimersRecording.First();
- while(tiR)
- {
+ while (tiR) {
// check if timer still exists
bool found = false;
for (const cTimer *ti = Timers->First(); ti; ti = Timers->Next(ti))
- if (ti == tiR->timer)
- {
+ if (ti == tiR->timer) {
found = true;
break;
}
- if (found && !tiR->timer->Recording())
- {
- if (tiR->recDone)
- {
+ if (found && !tiR->timer->Recording()) {
+ if (tiR->recDone) {
cSearchExt* search = SearchExts.GetSearchFromID(tiR->recDone->searchID);
if (!search) return;
// check if recording has ended before timer end
@@ -115,31 +109,26 @@ void cRecdoneThread::Action(void)
LOCK_RECORDINGS_READ;
pRecording = Recordings->GetByName(m_filename);
}
- long timerLengthSecs = tiR->timer->StopTime()-tiR->timer->StartTime();
+ long timerLengthSecs = tiR->timer->StopTime() - tiR->timer->StartTime();
int recFraction = 100;
- if (pRecording && timerLengthSecs)
- {
+ if (pRecording && timerLengthSecs) {
int recLen = RecLengthInSecs(pRecording);
recFraction = double(recLen) * 100 / timerLengthSecs;
}
bool vpsUsed = tiR->timer->HasFlags(tfVps) && tiR->timer->Event() && tiR->timer->Event()->Vps();
- if ((!vpsUsed && now < tiR->timer->StopTime()) || recFraction < (vpsUsed ? 90: 98)) // assure timer has reached its end or at least 98% were recorded
- {
+ if ((!vpsUsed && now < tiR->timer->StopTime()) || recFraction < (vpsUsed ? 90 : 98)) { // assure timer has reached its end or at least 98% were recorded
complete = false;
- LogFile.Log(1,"finished: '%s' (not complete! - recorded only %d%%); search timer: '%s'; VPS used: %s", tiR->timer->File(), recFraction, search->search, vpsUsed ? "Yes": "No");
- }
- else
- {
- LogFile.Log(1,"finished: '%s'; search timer: '%s'; VPS used: %s", tiR->timer->File(), search->search, vpsUsed ? "Yes": "No");
+ LogFile.Log(1, "finished: '%s' (not complete! - recorded only %d%%); search timer: '%s'; VPS used: %s", tiR->timer->File(), recFraction, search->search, vpsUsed ? "Yes" : "No");
+ } else {
+ LogFile.Log(1, "finished: '%s'; search timer: '%s'; VPS used: %s", tiR->timer->File(), search->search, vpsUsed ? "Yes" : "No");
if (recFraction < 100)
- LogFile.Log(2,"recorded %d%%'", recFraction);
+ LogFile.Log(2, "recorded %d%%'", recFraction);
}
- if (complete)
- {
+ if (complete) {
RecsDone.Add(tiR->recDone);
- LogFile.Log(1,"added rec done for '%s~%s';%s", tiR->recDone->title?tiR->recDone->title:"unknown title",
- tiR->recDone->shortText?tiR->recDone->shortText:"unknown subtitle",
- search->search);
+ LogFile.Log(1, "added rec done for '%s~%s';%s", tiR->recDone->title ? tiR->recDone->title : "unknown title",
+ tiR->recDone->shortText ? tiR->recDone->shortText : "unknown subtitle",
+ search->search);
RecsDone.Save();
tiR->recDone = NULL; // prevent deletion
tiR->lastBreak = 0;
@@ -150,12 +139,11 @@ void cRecdoneThread::Action(void)
// trigger a search timer update (skip running events)
search->skipRunningEvents = true;
updateForced = 1;
- }
- else if (tiR->lastBreak == 0) // store first break
+ } else if (tiR->lastBreak == 0) // store first break
tiR->lastBreak = now;
}
- if (tiR->lastBreak == 0 || (now - tiR->lastBreak) > ALLOWED_BREAK_INSECS)
- { // remove finished recordings or those with an unallowed break
+ if (tiR->lastBreak == 0 || (now - tiR->lastBreak) > ALLOWED_BREAK_INSECS) {
+ // remove finished recordings or those with an unallowed break
if (tiR->recDone) delete tiR->recDone; // clean up
cRecDoneTimerObj *tiRNext = TimersRecording.Next(tiR);
TimersRecording.Del(tiR);
@@ -164,8 +152,7 @@ void cRecdoneThread::Action(void)
}
break;
}
- if (!found)
- {
+ if (!found) {
if (tiR->recDone) delete tiR->recDone; // clean up
cRecDoneTimerObj *tiRNext = TimersRecording.Next(tiR);
TimersRecording.Del(tiR);
@@ -176,5 +163,5 @@ void cRecdoneThread::Action(void)
}
m_fnames.erase(it);
} // while fnames
- LogFile.Log(1,"recdone_thread ended");
+ LogFile.Log(1, "recdone_thread ended");
}
diff --git a/recdone_thread.h b/recdone_thread.h
index 43f5f3d..848804d 100644
--- a/recdone_thread.h
+++ b/recdone_thread.h
@@ -29,18 +29,19 @@ Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
using std::vector;
using std::string;
-class cRecdoneThread: public cThread {
+class cRecdoneThread: public cThread
+{
private:
vector<string>m_fnames;
public:
- virtual void Action(void);
- cRecdoneThread(void);
- virtual ~cRecdoneThread();
- void SetFilename(const char *FileName) {
- m_fnames.push_back(FileName);
- }
- int RecLengthInSecs(const cRecording *pRecording);
- bool IsPesRecording(const cRecording *pRecording);
+ virtual void Action(void);
+ cRecdoneThread(void);
+ virtual ~cRecdoneThread();
+ void SetFilename(const char *FileName) {
+ m_fnames.push_back(FileName);
+ }
+ int RecLengthInSecs(const cRecording *pRecording);
+ bool IsPesRecording(const cRecording *pRecording);
};
#endif
diff --git a/recstatus.c b/recstatus.c
index 20a31a6..408f159 100644
--- a/recstatus.c
+++ b/recstatus.c
@@ -41,82 +41,72 @@ cRecStatusMonitor::cRecStatusMonitor()
void cRecStatusMonitor::Recording(const cDevice *Device, const char *Name, const char* Filename, bool On)
{
- time_t now = time(NULL);
- // insert new timers currently recording in TimersRecording
- if (On && Name)
- {
- if (EPGSearchConfig.checkTimerConflOnRecording)
- cConflictCheckThread::Init((cPluginEpgsearch*)cPluginManager::GetPlugin("epgsearch"), true);
-
- LOCK_TIMERS_READ;
- for (const cTimer *ti = Timers->First(); ti; ti = Timers->Next(ti))
- if (ti->Recording())
- {
- // check if this is a new entry
- cRecDoneTimerObj *tiRFound = NULL;
- cMutexLock TimersRecordingLock(&TimersRecording);
- for (cRecDoneTimerObj *tiR = TimersRecording.First(); tiR; tiR = TimersRecording.Next(tiR))
- if (tiR->timer == ti)
- {
- tiRFound = tiR;
- break;
- }
-
- if (tiRFound) // already handled, perhaps a resume
- {
- if (tiRFound->lastBreak > 0 && now - tiRFound->lastBreak <= ALLOWED_BREAK_INSECS)
- {
- LogFile.Log(1,"accepting resume of '%s' on device %d", Name, Device->CardIndex());
- tiRFound->lastBreak = 0;
- }
- continue;
+ time_t now = time(NULL);
+ // insert new timers currently recording in TimersRecording
+ if (On && Name) {
+ if (EPGSearchConfig.checkTimerConflOnRecording)
+ cConflictCheckThread::Init((cPluginEpgsearch*)cPluginManager::GetPlugin("epgsearch"), true);
+
+ LOCK_TIMERS_READ;
+ for (const cTimer *ti = Timers->First(); ti; ti = Timers->Next(ti))
+ if (ti->Recording()) {
+ // check if this is a new entry
+ cRecDoneTimerObj *tiRFound = NULL;
+ cMutexLock TimersRecordingLock(&TimersRecording);
+ for (cRecDoneTimerObj *tiR = TimersRecording.First(); tiR; tiR = TimersRecording.Next(tiR))
+ if (tiR->timer == ti) {
+ tiRFound = tiR;
+ break;
+ }
+
+ if (tiRFound) { // already handled, perhaps a resume
+ if (tiRFound->lastBreak > 0 && now - tiRFound->lastBreak <= ALLOWED_BREAK_INSECS) {
+ LogFile.Log(1, "accepting resume of '%s' on device %d", Name, Device->CardIndex());
+ tiRFound->lastBreak = 0;
+ }
+ continue;
+ }
+
+ cRecDoneTimerObj* timerObj = new cRecDoneTimerObj(ti, Device->DeviceNumber());
+ TimersRecording.Add(timerObj);
+
+ cSearchExt* search = TriggeredFromSearchTimer(ti);
+ if (!search || (search->avoidRepeats == 0 && search->delMode == 0)) // ignore if not avoid repeats and no auto-delete
+ continue;
+
+ bool vpsUsed = ti->HasFlags(tfVps) && ti->Event() && ti->Event()->Vps();
+ LogFile.Log(1, "recording started '%s' on device %d (search timer '%s'); VPS used: %s", Name, Device->CardIndex(), search->search, vpsUsed ? "Yes" : "No");
+ const cEvent* event = ti->Event();
+ if (!event) {
+ event = GetEvent(ti);
+ if (event)
+ LogFile.Log(3, "timer had no event: assigning '%s'", event->Title());
+ }
+ if (!event) {
+ LogFile.Log(1, "no event for timer found! will be ignored in done list");
+ continue;
+ }
+ time_t now = time(NULL);
+ if (vpsUsed || now < ti->StartTime() + 60) { // allow a delay of one minute
+ timerObj->recDone = new cRecDone(ti, event, search);
+ return;
+ } else
+ LogFile.Log(1, "recording started too late! will be ignored");
}
+ }
- cRecDoneTimerObj* timerObj = new cRecDoneTimerObj(ti, Device->DeviceNumber());
- TimersRecording.Add(timerObj);
-
- cSearchExt* search = TriggeredFromSearchTimer(ti);
- if (!search || (search->avoidRepeats == 0 && search->delMode == 0)) // ignore if not avoid repeats and no auto-delete
- continue;
-
- bool vpsUsed = ti->HasFlags(tfVps) && ti->Event() && ti->Event()->Vps();
- LogFile.Log(1,"recording started '%s' on device %d (search timer '%s'); VPS used: %s", Name, Device->CardIndex(), search->search, vpsUsed ? "Yes": "No");
- const cEvent* event = ti->Event();
- if (!event)
- {
- event = GetEvent(ti);
- if (event)
- LogFile.Log(3,"timer had no event: assigning '%s'", event->Title());
- }
- if (!event)
- {
- LogFile.Log(1,"no event for timer found! will be ignored in done list");
- continue;
- }
- time_t now = time(NULL);
- if (vpsUsed || now < ti->StartTime() + 60) // allow a delay of one minute
- {
- timerObj->recDone = new cRecDone(ti, event, search);
- return;
- }
- else
- LogFile.Log(1,"recording started too late! will be ignored");
- }
- }
-
- if (!On)
- {
- // must be done in a different thread because we hold timer and scheduling lock here
- RecdoneThread.SetFilename(Filename); // push_back Filename for processing
- RecdoneThread.Start();
- }
+ if (!On) {
+ // must be done in a different thread because we hold timer and scheduling lock here
+ RecdoneThread.SetFilename(Filename); // push_back Filename for processing
+ RecdoneThread.Start();
+ }
}
int cRecStatusMonitor::TimerRecDevice(const cTimer* timer)
{
- if (!timer) return 0;
- cMutexLock TimersRecordingLock(&TimersRecording);
- for (cRecDoneTimerObj *tiR = TimersRecording.First(); tiR; tiR = TimersRecording.Next(tiR))
- if (tiR->timer == timer && timer->Recording()) return tiR->deviceNr+1;
- return 0;
+ if (!timer) return 0;
+ cMutexLock TimersRecordingLock(&TimersRecording);
+ for (cRecDoneTimerObj *tiR = TimersRecording.First(); tiR; tiR = TimersRecording.Next(tiR))
+ if (tiR->timer == timer && timer->Recording()) return tiR->deviceNr + 1;
+ return 0;
}
diff --git a/recstatus.h b/recstatus.h
index dcc6fec..47d5b3a 100644
--- a/recstatus.h
+++ b/recstatus.h
@@ -29,17 +29,22 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "epgsearchtools.h"
// --- cRecDoneTimerObj --------------------------------------------------------
-class cRecDoneTimerObj : public cTimerObj {
+class cRecDoneTimerObj : public cTimerObj
+{
public:
int deviceNr;
cRecDone* recDone;
time_t lastBreak;
public:
cRecDoneTimerObj(const cTimer* Timer, int DeviceNr) : cTimerObj(Timer), deviceNr(DeviceNr), recDone(NULL), lastBreak(0) {}
- ~cRecDoneTimerObj() { timer = NULL; recDone = NULL; } // do not delete anything!
+ ~cRecDoneTimerObj() {
+ timer = NULL; // do not delete anything!
+ recDone = NULL;
+ }
};
-class cTimersRecording: public cList<cRecDoneTimerObj>, public cMutex {
+class cTimersRecording: public cList<cRecDoneTimerObj>, public cMutex
+{
};
extern cTimersRecording TimersRecording;
@@ -48,7 +53,7 @@ class cRecStatusMonitor : public cStatus
{
protected:
virtual void Recording(const cDevice *Device, const char *Name, const char*, bool On);
- public:
+public:
cRecStatusMonitor();
int TimerRecDevice(const cTimer*);
};
diff --git a/searchtimer_thread.c b/searchtimer_thread.c
index ba54566..a879487 100644
--- a/searchtimer_thread.c
+++ b/searchtimer_thread.c
@@ -58,996 +58,912 @@ cSearchResults cSearchTimerThread::announceList;
bool cSearchTimerThread::justRunning = false;
cSearchTimerThread::cSearchTimerThread(cPluginEpgsearch* thePlugin)
- : cThread("EPGSearch: searchtimer")
+ : cThread("EPGSearch: searchtimer")
{
- m_plugin = thePlugin;
- m_Active = false;
- m_lastUpdate = time(NULL);
+ m_plugin = thePlugin;
+ m_Active = false;
+ m_lastUpdate = time(NULL);
}
-cSearchTimerThread::~cSearchTimerThread() {
- if (m_Active)
- Stop();
+cSearchTimerThread::~cSearchTimerThread()
+{
+ if (m_Active)
+ Stop();
}
void cSearchTimerThread::Init(cPluginEpgsearch* thePlugin, bool activatePermanently)
{
- if (activatePermanently)
- {
- EPGSearchConfig.useSearchTimers = 1;
- thePlugin->SetupStore("UseSearchTimers", EPGSearchConfig.useSearchTimers);
- }
- if (!EPGSearchConfig.useSearchTimers)
- return;
- if (m_Instance == NULL) {
- m_Instance = new cSearchTimerThread(thePlugin);
- m_Instance->Start();
- }
+ if (activatePermanently) {
+ EPGSearchConfig.useSearchTimers = 1;
+ thePlugin->SetupStore("UseSearchTimers", EPGSearchConfig.useSearchTimers);
+ }
+ if (!EPGSearchConfig.useSearchTimers)
+ return;
+ if (m_Instance == NULL) {
+ m_Instance = new cSearchTimerThread(thePlugin);
+ m_Instance->Start();
+ }
}
-void cSearchTimerThread::Exit(void) {
- if (m_Instance != NULL) {
- m_Instance->Stop();
- DELETENULL(m_Instance);
- }
+void cSearchTimerThread::Exit(void)
+{
+ if (m_Instance != NULL) {
+ m_Instance->Stop();
+ DELETENULL(m_Instance);
+ }
}
-void cSearchTimerThread::Stop(void) {
- m_Active = false;
- Wait.Signal();
- Cancel(6);
+void cSearchTimerThread::Stop(void)
+{
+ m_Active = false;
+ Wait.Signal();
+ Cancel(6);
}
const cTimer *cSearchTimerThread::GetTimer(cSearchExt *searchExt, const cEvent *pEvent, bool& bTimesMatchExactly)
{
- LOCK_TIMERS_READ;
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(pEvent->ChannelID(), true, true);
- if (!channel)
- return NULL;
-
- struct tm tm_r;
-
- bool UseVPS = searchExt->useVPS && pEvent->Vps() && Setup.UseVps;
- time_t eStart = pEvent->StartTime();
- time_t eStop = pEvent->EndTime();
- int eDuration = pEvent->Duration();
-
- int AllowedDiff = (eDuration < 10*60) ? (eDuration / 60): 10; // allowed start/stop difference
-
- int testVpsStart = 0;
- int testVpsStop = 0;
- time_t testVpsDay = 0;
- if (UseVPS)
- {
- eStart = pEvent->Vps();
- eStop = eStart + pEvent->Duration();
- cTimer VpsTestTimer(pEvent);
- testVpsStart = cTimer::TimeToInt(VpsTestTimer.Start());
- testVpsStop = cTimer::TimeToInt(VpsTestTimer.Stop());
- testVpsDay = VpsTestTimer.Day();
- }
-
- tm *tmStartEv = localtime_r(&eStart, &tm_r);
-
- for (const cTimer *ti = Timers->First(); ti; ti = Timers->Next(ti))
- {
- if (ti->Channel() != channel)
- continue;
-
- if (ti->WeekDays()) // ignore serial timers
- continue;
-
- if (ti->Remote()) // ignore remote timers
- continue;
- // ignore manual timers if this search could modify them
- if ((searchExt->action == searchTimerActionRecord || searchExt->action == searchTimerActionInactiveRecord) && TriggeredFromSearchTimerID(ti) == -1) // manual timer
- continue;
-
- if (UseVPS && ti->HasFlags(tfVps))
- {
- if (testVpsDay != ti->Day()) continue;
- int timerVpsStart = cTimer::TimeToInt(ti->Start());
- int timerVpsStop = cTimer::TimeToInt(ti->Stop());
-
- if (abs(testVpsStart - timerVpsStart) > AllowedDiff * 60) continue;
- if (abs(testVpsStop - timerVpsStop) > AllowedDiff * 60) continue;
-
- bTimesMatchExactly = (testVpsStart == timerVpsStart && testVpsStop == timerVpsStop);
- return ti;
- }
- else
- {
- time_t tStart = ti->StartTime() + searchExt->MarginStart * 60;
- time_t tStop = ti->StopTime() - searchExt->MarginStop * 60;
- tm *tmStartTi = localtime_r(&tStart, &tm_r);
- if (tmStartEv->tm_mday != tmStartTi->tm_mday)
+ LOCK_TIMERS_READ;
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(pEvent->ChannelID(), true, true);
+ if (!channel)
+ return NULL;
+
+ struct tm tm_r;
+
+ bool UseVPS = searchExt->useVPS && pEvent->Vps() && Setup.UseVps;
+ time_t eStart = pEvent->StartTime();
+ time_t eStop = pEvent->EndTime();
+ int eDuration = pEvent->Duration();
+
+ int AllowedDiff = (eDuration < 10 * 60) ? (eDuration / 60) : 10; // allowed start/stop difference
+
+ int testVpsStart = 0;
+ int testVpsStop = 0;
+ time_t testVpsDay = 0;
+ if (UseVPS) {
+ eStart = pEvent->Vps();
+ eStop = eStart + pEvent->Duration();
+ cTimer VpsTestTimer(pEvent);
+ testVpsStart = cTimer::TimeToInt(VpsTestTimer.Start());
+ testVpsStop = cTimer::TimeToInt(VpsTestTimer.Stop());
+ testVpsDay = VpsTestTimer.Day();
+ }
+
+ tm *tmStartEv = localtime_r(&eStart, &tm_r);
+
+ for (const cTimer *ti = Timers->First(); ti; ti = Timers->Next(ti)) {
+ if (ti->Channel() != channel)
+ continue;
+
+ if (ti->WeekDays()) // ignore serial timers
continue;
- // some providers change EPG times only for a few seconds
- // ignore this to avoid search timer mails because of such changes
- bTimesMatchExactly = (abs(tStart -eStart) < 60 && abs(tStop - eStop) < 60);
+ if (ti->Remote()) // ignore remote timers
+ continue;
+ // ignore manual timers if this search could modify them
+ if ((searchExt->action == searchTimerActionRecord || searchExt->action == searchTimerActionInactiveRecord) && TriggeredFromSearchTimerID(ti) == -1) // manual timer
+ continue;
+
+ if (UseVPS && ti->HasFlags(tfVps)) {
+ if (testVpsDay != ti->Day()) continue;
+ int timerVpsStart = cTimer::TimeToInt(ti->Start());
+ int timerVpsStop = cTimer::TimeToInt(ti->Stop());
- if (abs(tStart - eStart) < AllowedDiff * 60 && abs(tStop - eStop) < AllowedDiff * 60) // accept a difference of max 10 min., but only if the event duration is more than 10 minutes
+ if (abs(testVpsStart - timerVpsStart) > AllowedDiff * 60) continue;
+ if (abs(testVpsStop - timerVpsStop) > AllowedDiff * 60) continue;
+
+ bTimesMatchExactly = (testVpsStart == timerVpsStart && testVpsStop == timerVpsStop);
return ti;
- }
- }
- return NULL;
+ } else {
+ time_t tStart = ti->StartTime() + searchExt->MarginStart * 60;
+ time_t tStop = ti->StopTime() - searchExt->MarginStop * 60;
+ tm *tmStartTi = localtime_r(&tStart, &tm_r);
+ if (tmStartEv->tm_mday != tmStartTi->tm_mday)
+ continue;
+
+ // some providers change EPG times only for a few seconds
+ // ignore this to avoid search timer mails because of such changes
+ bTimesMatchExactly = (abs(tStart - eStart) < 60 && abs(tStop - eStop) < 60);
+
+ if (abs(tStart - eStart) < AllowedDiff * 60 && abs(tStop - eStop) < AllowedDiff * 60) // accept a difference of max 10 min., but only if the event duration is more than 10 minutes
+ return ti;
+ }
+ }
+ return NULL;
}
bool cSearchTimerThread::TimerWasModified(const cTimer* t)
{
- if (!t) return false;
- if (t->HasFlags(tfVps)) return false; // if timer uses VPS we ignore user changes
-
- char* start = GetAuxValue(t, "start");
- char* stop = GetAuxValue(t, "stop");
- bool bMod = false;
- if (start || stop)
- {
- time_t StartTime = time_t(atol(start));
- time_t StopTime = time_t(atol(stop));
- if (abs(t->StartTime() - StartTime) >= 60 || abs(t->StopTime() -StopTime) >= 60)
- bMod = true;
- }
- if (start) free(start);
- if (stop) free(stop);
- return bMod;
+ if (!t) return false;
+ if (t->HasFlags(tfVps)) return false; // if timer uses VPS we ignore user changes
+
+ char* start = GetAuxValue(t, "start");
+ char* stop = GetAuxValue(t, "stop");
+ bool bMod = false;
+ if (start || stop) {
+ time_t StartTime = time_t(atol(start));
+ time_t StopTime = time_t(atol(stop));
+ if (abs(t->StartTime() - StartTime) >= 60 || abs(t->StopTime() - StopTime) >= 60)
+ bMod = true;
+ }
+ if (start) free(start);
+ if (stop) free(stop);
+ return bMod;
}
void cSearchTimerThread::Action(void)
{
- if (EPGSearchConfig.useExternalSVDRP && !epgsSVDRP::cSVDRPClient::SVDRPSendCmd)
- {
- LogFile.eSysLog("ERROR - SVDRPSend script not specified or does not exist (use -f option)");
- return;
- }
- SetPriority(SEARCHTIMER_NICE);
-
- m_Active = true;
- // let VDR do its startup
- if (!cPluginEpgsearch::VDR_readyafterStartup)
- LogFile.Log(2, "SearchTimerThread: waiting for VDR to become ready...");
- while(Running() && m_Active && !cPluginEpgsearch::VDR_readyafterStartup)
- Wait.Wait(1000);
-
- time_t nextUpdate = time(NULL);
- while (m_Active && Running())
- {
- time_t now = time(NULL);
- bool needUpdate = NeedUpdate();
- if (now >= nextUpdate || needUpdate)
- {
- justRunning = true;
-
- if (updateForced & UPDS_WITH_EPGSCAN)
- {
- LogFile.Log(1,"starting EPG scan before search timer update");
- EITScanner.ForceScan();
- do
- {
- Wait.Wait(1000);
- }
- while(EITScanner.Active() && m_Active && Running());
- LogFile.Log(1,"EPG scan finished");
- }
- // wait if TimersWriteLock is set or waited for
- {
- LOCK_TIMERS_WRITE;
- Timers->SetExplicitModify();
- }
- LogFile.iSysLog("search timer update started");
-
- UserVars.ResetCache(); // reset internal cache of user vars
- cTimerObjList* pOutdatedTimers = NULL;
-
- // for thread safeness we work with a copy of the current searches,
- // because SVDRP would not work if the main thread would be locked
- cSearchExts* localSearchExts = SearchExts.Clone();
- localSearchExts->SortBy(CompareSearchExtPrioDescTerm);
- cSearchExt *searchExt = localSearchExts->First();
- // reset announcelist
- announceList.Clear();
- while (searchExt && m_Active && Running())
- {
- if (!searchExt->IsActiveAt(now))
- {
- searchExt = localSearchExts->Next(searchExt);
- continue;
+ if (EPGSearchConfig.useExternalSVDRP && !epgsSVDRP::cSVDRPClient::SVDRPSendCmd) {
+ LogFile.eSysLog("ERROR - SVDRPSend script not specified or does not exist (use -f option)");
+ return;
+ }
+ SetPriority(SEARCHTIMER_NICE);
+
+ m_Active = true;
+ // let VDR do its startup
+ if (!cPluginEpgsearch::VDR_readyafterStartup)
+ LogFile.Log(2, "SearchTimerThread: waiting for VDR to become ready...");
+ while (Running() && m_Active && !cPluginEpgsearch::VDR_readyafterStartup)
+ Wait.Wait(1000);
+
+ time_t nextUpdate = time(NULL);
+ while (m_Active && Running()) {
+ time_t now = time(NULL);
+ bool needUpdate = NeedUpdate();
+ if (now >= nextUpdate || needUpdate) {
+ justRunning = true;
+
+ if (updateForced & UPDS_WITH_EPGSCAN) {
+ LogFile.Log(1, "starting EPG scan before search timer update");
+ EITScanner.ForceScan();
+ do {
+ Wait.Wait(1000);
+ } while (EITScanner.Active() && m_Active && Running());
+ LogFile.Log(1, "EPG scan finished");
}
- pOutdatedTimers = searchExt->GetTimerList(pOutdatedTimers);
-
- cSearchResults* pSearchResults = searchExt->Run(-1, true);
- if (!pSearchResults)
+ // wait if TimersWriteLock is set or waited for
{
- searchExt = localSearchExts->Next(searchExt);
- continue;
+ LOCK_TIMERS_WRITE;
+ Timers->SetExplicitModify();
+ }
+ LogFile.iSysLog("search timer update started");
+
+ UserVars.ResetCache(); // reset internal cache of user vars
+ cTimerObjList* pOutdatedTimers = NULL;
+
+ // for thread safeness we work with a copy of the current searches,
+ // because SVDRP would not work if the main thread would be locked
+ cSearchExts* localSearchExts = SearchExts.Clone();
+ localSearchExts->SortBy(CompareSearchExtPrioDescTerm);
+ cSearchExt *searchExt = localSearchExts->First();
+ // reset announcelist
+ announceList.Clear();
+ while (searchExt && m_Active && Running()) {
+ if (!searchExt->IsActiveAt(now)) {
+ searchExt = localSearchExts->Next(searchExt);
+ continue;
+ }
+ pOutdatedTimers = searchExt->GetTimerList(pOutdatedTimers);
+
+ cSearchResults* pSearchResults = searchExt->Run(-1, true);
+ if (!pSearchResults) {
+ searchExt = localSearchExts->Next(searchExt);
+ continue;
+ }
+ pSearchResults->SortBy(CompareEventTime);
+
+ if (searchExt->pauseOnNrRecordings > 0)
+ searchExt->CheckExistingRecordings(pSearchResults);
+
+ for (cSearchResult* pResultObj = pSearchResults->First();
+ pResultObj;
+ pResultObj = pSearchResults->Next(pResultObj)) {
+ if (!Running()) break;
+ const cEvent* pEvent = pResultObj->event;
+ if (!pEvent)
+ continue;
+
+ {
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(pEvent->ChannelID(), true, true);
+ if (!channel)
+ continue;
+ }
+
+ int index = 0;
+ cTimer *timer = new cTimer(pEvent);
+
+ // create the file
+ char* file = NULL;
+ if ((file = searchExt->BuildFile(pEvent)) != NULL) {
+ while (strstr(file, "!^pipe^!")) file = strreplace(file, "!^pipe^!", "|"); // revert the translation of '|' in BuildFile
+ if (strstr(file, "!^invalid^!") || strlen(file) == 0) {
+ LogFile.eSysLog("Skipping timer due to invalid or empty filename");
+ if (time(NULL) <= timer->StopTime())
+ pOutdatedTimers->DelTimer(timer);
+ delete timer;
+ free(file);
+ continue;
+ }
+ timer->SetFile(file);
+ free(file);
+ }
+ int Priority = searchExt->Priority;
+ int Lifetime = searchExt->Lifetime;
+
+ // search for an already existing timer
+ bool bTimesMatchExactly = false;
+ const cTimer *t = GetTimer(searchExt, pEvent, bTimesMatchExactly);
+
+ char* Summary = NULL;
+ uint timerMod = tmNoChange;
+
+ if (t) {
+ // already exists
+ pOutdatedTimers->DelTimer(t);
+
+ if (!t->HasFlags(tfActive)) {
+ // do not update inactive timers
+ LogFile.Log(2, "timer for '%s~%s' (%s - %s, channel %d) not active - won't be touched", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
+ delete timer;
+ continue;
+ }
+
+ int triggerID = TriggeredFromSearchTimerID(t);
+ if (!pResultObj->needsTimer && !t->Recording()) { // not needed
+ if (triggerID == searchExt->ID) {
+ LogFile.Log(1, "delete timer for '%s~%s' (%s - %s, channel %d)", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
+ RemoveTimer(t, pEvent);
+ } else if (triggerID == -1) { //manual timer
+ LogFile.Log(2, "keep obsolete timer for '%s~%s' (%s - %s, channel %d) - was manually created", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
+ }
+ delete timer;
+ continue;
+ }
+ if (TimerWasModified(t)) { // don't touch timer modified by user
+ LogFile.Log(2, "timer for '%s~%s' (%s - %s, channel %d) modified by user - won't be touched", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
+ delete timer;
+ continue;
+ }
+ if (triggerID > -1 && triggerID != searchExt->ID) {
+ LogFile.Log(2, "timer for '%s~%s' (%s - %s, channel %d) already created by search id %d - won't be touched", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), triggerID);
+ delete timer;
+ continue;
+ }
+
+ char* pFile = NULL; // File is prepared for svdrp, so prepare t->File for comparison too
+ msprintf(&pFile, "%s", t->File());
+ pFile = strreplace(pFile, ':', '|');
+ pFile = strreplace(pFile, " ~", "~");
+ pFile = strreplace(pFile, "~ ", "~");
+
+ Summary = SummaryExtended(searchExt, t, pEvent);
+
+ if (bTimesMatchExactly && strcmp(pFile, timer->File()) == 0
+ && (t->Aux() != NULL && strcmp(t->Aux(), Summary) == 0)
+ ) {
+ // dir, title, episode name and summary have not changed
+ if (Summary) free(Summary);
+ delete timer;
+ free(pFile);
+ continue;
+ } else {
+ if (!bTimesMatchExactly) timerMod = (uint)timerMod | tmStartStop;
+ if (strcmp(pFile, timer->File()) != 0) timerMod |= tmFile;
+ if (t->Aux() != NULL && strcmp(t->Aux(), Summary) != 0) {
+ char* oldEventID = GetAuxValue(t, "eventid");
+ char* newEventID = GetAuxValue(Summary, "eventid");
+ if (oldEventID && newEventID && strcmp(oldEventID, newEventID) != 0)
+ timerMod |= tmAuxEventID;
+ free(oldEventID);
+ free(newEventID);
+ }
+
+ if (LogFile.Level() >= 3) { // output reasons for a timer modification
+ if (timerMod & tmStartStop)
+ LogFile.Log(3, "timer for '%s~%s' (%s - %s, channel %d) : start/stop has changed", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
+ if (timerMod & tmFile)
+ LogFile.Log(3, "timer for '%s~%s' (%s - %s, channel %d) : title and/or episdode has changed (old: %s, new: %s", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), timer ? timer->File() : "", pFile);
+ if (timerMod & tmAuxEventID)
+ LogFile.Log(3, "timer for '%s~%s' (%s - %s, channel %d) : aux info for event id has changed", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
+ }
+ index = t->Id();
+ Priority = t->Priority();
+ Lifetime = t->Lifetime();
+ }
+ free(pFile);
+
+ if (t->Recording() && t->StopTime() == timer->StopTime()) {
+ // only update recording timers if stop time has changed, since all other settings can't be modified
+ LogFile.Log(2, "timer for '%s~%s' (%s - %s, channel %d) already recording - no changes possible", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
+ delete timer;
+ continue;
+ }
+ } else {
+ if (!pResultObj->needsTimer) {
+ delete timer;
+ continue;
+ }
+ }
+
+ if (searchExt->action == searchTimerActionAnnounceViaOSD) {
+ if (t || // timer already exists or
+ NoAnnounces.InList(pEvent) || // announcement not wanted anymore or
+ (EPGSearchConfig.noAnnounceWhileReplay &&
+ cDevice::PrimaryDevice()->Replaying() &&
+ !(updateForced & UPDS_WITH_OSD)) // no announce while replay within automatic updates
+ ) {
+ if (Summary) free(Summary);
+ delete timer;
+ continue;
+ }
+ if (!announceList.Lookup(pEvent))
+ announceList.Add(new cSearchResult(pEvent, searchExt->ID));
+
+ if (Summary) free(Summary);
+ delete timer;
+ continue;
+ }
+
+ if (searchExt->action == searchTimerActionAnnounceViaMail) {
+ if (t || // timer already exists or
+ NoAnnounces.InList(pEvent) ||
+ pEvent->StartTime() < time(NULL)) { // already started?
+ if (Summary) free(Summary);
+ delete timer;
+ continue;
+ }
+ mailNotifier.AddAnnounceEventNotification(pEvent->EventID(), pEvent->ChannelID(), searchExt->ID);
+
+ if (Summary) free(Summary);
+ delete timer;
+ continue;
+ }
+ if (searchExt->action == searchTimerActionSwitchOnly ||
+ searchExt->action == searchTimerActionAnnounceAndSwitch) { // add to switch list
+ time_t now = time(NULL);
+ if (now < pEvent->StartTime()) {
+ if (!SwitchTimers.InSwitchList(pEvent)) {
+ cMutexLock SwitchTimersLock(&SwitchTimers);
+ int mode = 0;
+ if (searchExt->action == searchTimerActionAnnounceAndSwitch)
+ mode = 2;
+ LogFile.Log(3, "adding switch timer event for '%s~%s' (%s - %s); search timer: '%s'", pEvent->Title(), pEvent->ShortText() ? pEvent->ShortText() : "", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), searchExt->search);
+ SwitchTimers.Add(new cSwitchTimer(pEvent, searchExt->switchMinsBefore, mode,
+ searchExt->unmuteSoundOnSwitch));
+ SwitchTimers.Save();
+ cSwitchTimerThread::Init();
+ }
+ }
+ if (Summary) free(Summary);
+ delete timer;
+ continue;
+ }
+
+ if (AddModTimer(timer, index, searchExt, pEvent, Priority, Lifetime, Summary, timerMod)) {
+ if (index == 0)
+ LogFile.Log(1, "added timer for '%s~%s' (%s - %s); search timer: '%s'", pEvent->Title(), pEvent->ShortText() ? pEvent->ShortText() : "", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), searchExt->search);
+ else
+ LogFile.Log(1, "modified timer %d for '%s~%s' (%s - %s); search timer: '%s'", index, pEvent->Title(), pEvent->ShortText() ? pEvent->ShortText() : "", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), searchExt->search);
+ }
+ if (Summary) free(Summary);
+ delete timer;
+ }
+ delete pSearchResults;
+ searchExt = localSearchExts->Next(searchExt);
}
- pSearchResults->SortBy(CompareEventTime);
-
- if (searchExt->pauseOnNrRecordings > 0)
- searchExt->CheckExistingRecordings(pSearchResults);
- for (cSearchResult* pResultObj = pSearchResults->First();
- pResultObj;
- pResultObj = pSearchResults->Next(pResultObj))
- {
- if (!Running()) break;
- const cEvent* pEvent = pResultObj->event;
- if (!pEvent)
- continue;
-
- {
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(pEvent->ChannelID(), true, true);
- if (!channel)
- continue;
- }
-
- int index = 0;
- cTimer *timer = new cTimer(pEvent);
-
- // create the file
- char* file = NULL;
- if ((file = searchExt->BuildFile(pEvent)) != NULL)
- {
- while(strstr(file, "!^pipe^!")) file = strreplace(file, "!^pipe^!", "|"); // revert the translation of '|' in BuildFile
- if (strstr(file, "!^invalid^!") || strlen(file) == 0)
- {
- LogFile.eSysLog("Skipping timer due to invalid or empty filename");
- if (time(NULL) <= timer->StopTime())
- pOutdatedTimers->DelTimer(timer);
- delete timer;
- free(file);
- continue;
- }
- timer->SetFile(file);
- free(file);
- }
- int Priority = searchExt->Priority;
- int Lifetime = searchExt->Lifetime;
-
- // search for an already existing timer
- bool bTimesMatchExactly = false;
- const cTimer *t = GetTimer(searchExt, pEvent, bTimesMatchExactly);
-
- char* Summary = NULL;
- uint timerMod = tmNoChange;
-
- if (t)
- { // already exists
- pOutdatedTimers->DelTimer(t);
-
- if (!t->HasFlags(tfActive))
- { // do not update inactive timers
- LogFile.Log(2,"timer for '%s~%s' (%s - %s, channel %d) not active - won't be touched", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
- delete timer;
- continue;
- }
-
- int triggerID = TriggeredFromSearchTimerID(t);
- if (!pResultObj->needsTimer && !t->Recording()) // not needed
- {
- if (triggerID == searchExt->ID)
- {
- LogFile.Log(1,"delete timer for '%s~%s' (%s - %s, channel %d)", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
- RemoveTimer(t, pEvent);
- }
- else if (triggerID == -1) //manual timer
- {
- LogFile.Log(2,"keep obsolete timer for '%s~%s' (%s - %s, channel %d) - was manually created", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
- }
- delete timer;
- continue;
- }
- if (TimerWasModified(t)) // don't touch timer modified by user
- {
- LogFile.Log(2,"timer for '%s~%s' (%s - %s, channel %d) modified by user - won't be touched", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
- delete timer;
- continue;
- }
- if (triggerID > -1 && triggerID != searchExt->ID)
- {
- LogFile.Log(2,"timer for '%s~%s' (%s - %s, channel %d) already created by search id %d - won't be touched", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), triggerID);
- delete timer;
- continue;
- }
-
- char* pFile = NULL; // File is prepared for svdrp, so prepare t->File for comparison too
- msprintf(&pFile, "%s", t->File());
- pFile = strreplace(pFile, ':', '|');
- pFile = strreplace(pFile, " ~", "~");
- pFile = strreplace(pFile, "~ ", "~");
-
- Summary = SummaryExtended(searchExt, t, pEvent);
-
- if (bTimesMatchExactly && strcmp(pFile, timer->File()) == 0
- && (t->Aux() != NULL && strcmp(t->Aux(), Summary) == 0)
- )
- { // dir, title, episode name and summary have not changed
- if (Summary) free(Summary);
- delete timer;
- free(pFile);
- continue;
- }
- else
- {
- if (!bTimesMatchExactly) timerMod = (uint)timerMod | tmStartStop;
- if (strcmp(pFile, timer->File()) != 0) timerMod |= tmFile;
- if (t->Aux() != NULL && strcmp(t->Aux(), Summary) != 0)
- {
- char* oldEventID = GetAuxValue(t, "eventid");
- char* newEventID = GetAuxValue(Summary, "eventid");
- if (oldEventID && newEventID && strcmp(oldEventID, newEventID) != 0)
- timerMod |= tmAuxEventID;
- free(oldEventID);
- free(newEventID);
- }
-
- if (LogFile.Level() >= 3) // output reasons for a timer modification
- {
- if (timerMod & tmStartStop)
- LogFile.Log(3,"timer for '%s~%s' (%s - %s, channel %d) : start/stop has changed", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
- if (timerMod & tmFile)
- LogFile.Log(3,"timer for '%s~%s' (%s - %s, channel %d) : title and/or episdode has changed (old: %s, new: %s", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), timer?timer->File():"", pFile);
- if (timerMod & tmAuxEventID)
- LogFile.Log(3,"timer for '%s~%s' (%s - %s, channel %d) : aux info for event id has changed", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
- }
- index = t->Id();
- Priority = t->Priority();
- Lifetime = t->Lifetime();
- }
- free(pFile);
-
- if (t->Recording() && t->StopTime() == timer->StopTime())
- {
- // only update recording timers if stop time has changed, since all other settings can't be modified
- LogFile.Log(2,"timer for '%s~%s' (%s - %s, channel %d) already recording - no changes possible", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
- delete timer;
- continue;
- }
- }
- else
- {
- if (!pResultObj->needsTimer)
- {
- delete timer;
- continue;
- }
- }
-
- if (searchExt->action == searchTimerActionAnnounceViaOSD)
- {
- if (t || // timer already exists or
- NoAnnounces.InList(pEvent) || // announcement not wanted anymore or
- (EPGSearchConfig.noAnnounceWhileReplay &&
- cDevice::PrimaryDevice()->Replaying() &&
- !(updateForced & UPDS_WITH_OSD)) // no announce while replay within automatic updates
- )
- {
- if (Summary) free(Summary);
- delete timer;
- continue;
- }
- if (!announceList.Lookup(pEvent))
- announceList.Add(new cSearchResult(pEvent, searchExt->ID));
-
- if (Summary) free(Summary);
- delete timer;
- continue;
- }
-
- if (searchExt->action == searchTimerActionAnnounceViaMail)
- {
- if (t || // timer already exists or
- NoAnnounces.InList(pEvent) ||
- pEvent->StartTime() < time(NULL)) // already started?
- {
- if (Summary) free(Summary);
- delete timer;
- continue;
- }
- mailNotifier.AddAnnounceEventNotification(pEvent->EventID(), pEvent->ChannelID(), searchExt->ID);
-
- if (Summary) free(Summary);
- delete timer;
- continue;
- }
- if (searchExt->action == searchTimerActionSwitchOnly ||
- searchExt->action == searchTimerActionAnnounceAndSwitch) // add to switch list
- {
- time_t now = time(NULL);
- if (now < pEvent->StartTime())
- {
- if (!SwitchTimers.InSwitchList(pEvent))
- {
- cMutexLock SwitchTimersLock(&SwitchTimers);
- int mode = 0;
- if (searchExt->action == searchTimerActionAnnounceAndSwitch)
- mode = 2;
- LogFile.Log(3,"adding switch timer event for '%s~%s' (%s - %s); search timer: '%s'", pEvent->Title(), pEvent->ShortText()?pEvent->ShortText():"", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), searchExt->search);
- SwitchTimers.Add(new cSwitchTimer(pEvent, searchExt->switchMinsBefore, mode,
- searchExt->unmuteSoundOnSwitch));
- SwitchTimers.Save();
- cSwitchTimerThread::Init();
- }
- }
- if (Summary) free(Summary);
- delete timer;
- continue;
- }
-
- if (AddModTimer(timer, index, searchExt, pEvent, Priority, Lifetime, Summary, timerMod))
- {
- if (index == 0)
- LogFile.Log(1,"added timer for '%s~%s' (%s - %s); search timer: '%s'", pEvent->Title(), pEvent->ShortText()?pEvent->ShortText():"", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), searchExt->search);
- else
- LogFile.Log(1,"modified timer %d for '%s~%s' (%s - %s); search timer: '%s'", index, pEvent->Title(), pEvent->ShortText()?pEvent->ShortText():"", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), searchExt->search);
- }
- if (Summary) free(Summary);
- delete timer;
+ if (localSearchExts) delete localSearchExts;
+
+ if (pOutdatedTimers) {
+ if (pOutdatedTimers->Count() > 0) {
+ LogFile.Log(1, "removing outdated timers");
+ for (cTimerObj *tObj = pOutdatedTimers->First(); tObj; tObj = pOutdatedTimers->Next(tObj)) {
+ const cTimer* t = tObj->timer;
+ // timer could have been deleted meanwhile, so check if its still there
+ {
+ LOCK_TIMERS_READ;
+ if (!Timers->Contains(t))
+ continue;
+ }
+
+ if (TimerWasModified(t)) continue;
+ if (!t->Event()) continue; // if there is no event, we keep the timer, since EPG could have been cleared
+ if (time(NULL) > t->StopTime()) continue; // if this timer has (just) finished, let VDR do the cleanup
+ if (t->Recording()) continue; // do not remove recording timers
+ LogFile.Log(1, "delete timer for '%s' (%s, channel %s)", t->File(), DAYDATETIME(t->StartTime()), CHANNELNAME(t->Channel()));
+ RemoveTimer(t, t->Event());
+ }
+ LogFile.Log(1, "removing outdated timers - done");
+ }
+ delete pOutdatedTimers;
}
- delete pSearchResults;
- searchExt = localSearchExts->Next(searchExt);
- }
- if (localSearchExts) delete localSearchExts;
+ TimersDone.ClearOutdated();
+ TimersDone.Save();
- if (pOutdatedTimers)
- {
- if (pOutdatedTimers->Count() > 0)
- {
- LogFile.Log(1,"removing outdated timers");
- for(cTimerObj *tObj = pOutdatedTimers->First(); tObj; tObj = pOutdatedTimers->Next(tObj))
- {
- const cTimer* t = tObj->timer;
- // timer could have been deleted meanwhile, so check if its still there
- {
- LOCK_TIMERS_READ;
- if (!Timers->Contains(t))
- continue;
- }
-
- if (TimerWasModified(t)) continue;
- if (!t->Event()) continue; // if there is no event, we keep the timer, since EPG could have been cleared
- if (time(NULL) > t->StopTime()) continue; // if this timer has (just) finished, let VDR do the cleanup
- if (t->Recording()) continue; // do not remove recording timers
- LogFile.Log(1,"delete timer for '%s' (%s, channel %s)", t->File(), DAYDATETIME(t->StartTime()), CHANNELNAME(t->Channel()));
- RemoveTimer(t, t->Event());
- }
- LogFile.Log(1,"removing outdated timers - done");
- }
- delete pOutdatedTimers;
- }
-
- TimersDone.ClearOutdated();
- TimersDone.Save();
-
- if (announceList.Count() > 0)
- {
- cString msgfmt = cString::sprintf(tr("%d new broadcast(s) found! Show them?"), announceList.Count());
- if (SendMsg(msgfmt, true, 7) == kOk)
- {
- m_plugin->showAnnounces = true;
- cRemote::CallPlugin("epgsearch");
- }
- }
-
- CheckEPGHours();
-
- LogFile.iSysLog("search timer update finished");
-
- // check for conflicts
- if (EPGSearchConfig.checkTimerConflictsAfterUpdate && m_Active && Running())
- {
- LogFile.iSysLog("check for timer conflicts");
- cConflictCheck conflictCheck;
- conflictCheck.Check();
-
- if (conflictCheck.relevantConflicts > 0)
- {
- if (EPGSearchConfig.sendMailOnConflicts)
- {
- cMailConflictNotifier mailNotifier;
- mailNotifier.SendConflictNotifications(conflictCheck);
- }
-
- conflictCheck.EvaluateConflCheckCmd();
-
- 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 ||
- (updateForced & UPDS_WITH_OSD);
- if (doMessage && SendMsg(msgfmt, true,7,mtWarning) == kOk)
- {
- m_plugin->showConflicts = true;
- cRemote::CallPlugin("epgsearch");
- }
+ if (announceList.Count() > 0) {
+ cString msgfmt = cString::sprintf(tr("%d new broadcast(s) found! Show them?"), announceList.Count());
+ if (SendMsg(msgfmt, true, 7) == kOk) {
+ m_plugin->showAnnounces = true;
+ cRemote::CallPlugin("epgsearch");
+ }
}
- LogFile.iSysLog("check for timer conflicts - done");
- }
+ CheckEPGHours();
+
+ LogFile.iSysLog("search timer update finished");
+
+ // check for conflicts
+ if (EPGSearchConfig.checkTimerConflictsAfterUpdate && m_Active && Running()) {
+ LogFile.iSysLog("check for timer conflicts");
+ cConflictCheck conflictCheck;
+ conflictCheck.Check();
+
+ if (conflictCheck.relevantConflicts > 0) {
+ if (EPGSearchConfig.sendMailOnConflicts) {
+ cMailConflictNotifier mailNotifier;
+ mailNotifier.SendConflictNotifications(conflictCheck);
+ }
+
+ conflictCheck.EvaluateConflCheckCmd();
+
+ 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 ||
+ (updateForced & UPDS_WITH_OSD);
+ if (doMessage && SendMsg(msgfmt, true, 7, mtWarning) == kOk) {
+ m_plugin->showConflicts = true;
+ cRemote::CallPlugin("epgsearch");
+ }
+ }
+
+ LogFile.iSysLog("check for timer conflicts - done");
+ }
- // delete expired recordings
- CheckExpiredRecs();
+ // delete expired recordings
+ CheckExpiredRecs();
- // check for updates for manual timers
- CheckManualTimers();
+ // check for updates for manual timers
+ CheckManualTimers();
- if (m_Active)
- mailNotifier.SendUpdateNotifications();
+ if (m_Active)
+ mailNotifier.SendUpdateNotifications();
- if ((updateForced & UPDS_WITH_OSD) && m_Active)
- SendMsg(tr("Search timer update done!"));
+ if ((updateForced & UPDS_WITH_OSD) && m_Active)
+ SendMsg(tr("Search timer update done!"));
- // reset service call flag
- updateForced = 0;
+ // reset service call flag
+ updateForced = 0;
- m_lastUpdate = time(NULL);
- nextUpdate = long(m_lastUpdate/60)*60 + (EPGSearchConfig.UpdateIntervall * 60);
- justRunning = false;
- }
- if (m_Active && Running())
- Wait.Wait(2000); // to avoid high system load if time%30==0
- while (Running() && m_Active && !NeedUpdate() && time(NULL)%30 != 0) // sync heart beat to a multiple of 5secs
- Wait.Wait(1000);
- };
- LogFile.iSysLog("Leaving search timer thread");
+ m_lastUpdate = time(NULL);
+ nextUpdate = long(m_lastUpdate / 60) * 60 + (EPGSearchConfig.UpdateIntervall * 60);
+ justRunning = false;
+ }
+ if (m_Active && Running())
+ Wait.Wait(2000); // to avoid high system load if time%30==0
+ while (Running() && m_Active && !NeedUpdate() && time(NULL) % 30 != 0) // sync heart beat to a multiple of 5secs
+ Wait.Wait(1000);
+ };
+ LogFile.iSysLog("Leaving search timer thread");
}
bool cSearchTimerThread::NeedUpdate()
{
- return (m_lastUpdate <= LastModifiedTime(AddDirectory(CONFIGDIR, ".epgsearchupdate")) || updateForced>0);
+ return (m_lastUpdate <= LastModifiedTime(AddDirectory(CONFIGDIR, ".epgsearchupdate")) || updateForced > 0);
}
char* cSearchTimerThread::SummaryExtended(cSearchExt* searchExt, const cTimer* Timer, const cEvent* pEvent)
{
- bool UseVPS = searchExt->useVPS && pEvent->Vps() && Setup.UseVps;
- time_t eStart;
- if (!UseVPS)
- eStart = pEvent->StartTime();
- else
- eStart = pEvent->Vps();
- time_t eStop;
- if (!UseVPS)
- eStop = pEvent->EndTime();
- else
- eStop = pEvent->Vps() + pEvent->Duration();
- // make sure that eStart and eStop represent a full minute
- eStart = (eStart / 60) * 60;
- eStop = (eStop / 60) * 60;
-
- time_t start = eStart - (UseVPS?0:(searchExt->MarginStart * 60));
- time_t stop = eStop + (UseVPS?0:(searchExt->MarginStop * 60));
-
- char* addSummaryFooter = NULL;
- msprintf(&addSummaryFooter, "<channel>%d - %s</channel><searchtimer>%s</searchtimer><start>%ld</start><stop>%ld</stop><s-id>%d</s-id><eventid>%ld</eventid>",
- Timer->Channel()->Number(), CHANNELNAME(Timer->Channel()),
- searchExt->search,
- start,
- stop,
- searchExt->ID,
- (long) pEvent->EventID());
-
- const char* aux = Timer->Aux();
- // remove epgsearch entries
- char* tmpaux = NULL;
- if (!isempty(aux))
- {
- tmpaux = strdup(aux);
- const char* begin = strstr(aux, "<epgsearch>");
- const char* end = strstr(aux, "</epgsearch>");
- if (begin && end)
- {
- if (begin == aux) strcpy(tmpaux, ""); else strn0cpy(tmpaux, aux, begin-aux+1);
- strcat(tmpaux, end + strlen("</epgsearch>"));
- }
- }
-
- char* tmpSummary = NULL;
- msprintf(&tmpSummary, "<epgsearch>%s</epgsearch>%s", addSummaryFooter, tmpaux?tmpaux:"");
- free(addSummaryFooter);
- if (tmpaux) free(tmpaux);
- return tmpSummary;
+ bool UseVPS = searchExt->useVPS && pEvent->Vps() && Setup.UseVps;
+ time_t eStart;
+ if (!UseVPS)
+ eStart = pEvent->StartTime();
+ else
+ eStart = pEvent->Vps();
+ time_t eStop;
+ if (!UseVPS)
+ eStop = pEvent->EndTime();
+ else
+ eStop = pEvent->Vps() + pEvent->Duration();
+ // make sure that eStart and eStop represent a full minute
+ eStart = (eStart / 60) * 60;
+ eStop = (eStop / 60) * 60;
+
+ time_t start = eStart - (UseVPS ? 0 : (searchExt->MarginStart * 60));
+ time_t stop = eStop + (UseVPS ? 0 : (searchExt->MarginStop * 60));
+
+ char* addSummaryFooter = NULL;
+ msprintf(&addSummaryFooter, "<channel>%d - %s</channel><searchtimer>%s</searchtimer><start>%ld</start><stop>%ld</stop><s-id>%d</s-id><eventid>%ld</eventid>",
+ Timer->Channel()->Number(), CHANNELNAME(Timer->Channel()),
+ searchExt->search,
+ start,
+ stop,
+ searchExt->ID,
+ (long) pEvent->EventID());
+
+ const char* aux = Timer->Aux();
+ // remove epgsearch entries
+ char* tmpaux = NULL;
+ if (!isempty(aux)) {
+ tmpaux = strdup(aux);
+ const char* begin = strstr(aux, "<epgsearch>");
+ const char* end = strstr(aux, "</epgsearch>");
+ if (begin && end) {
+ if (begin == aux) strcpy(tmpaux, "");
+ else strn0cpy(tmpaux, aux, begin - aux + 1);
+ strcat(tmpaux, end + strlen("</epgsearch>"));
+ }
+ }
+
+ char* tmpSummary = NULL;
+ msprintf(&tmpSummary, "<epgsearch>%s</epgsearch>%s", addSummaryFooter, tmpaux ? tmpaux : "");
+ free(addSummaryFooter);
+ if (tmpaux) free(tmpaux);
+ return tmpSummary;
}
bool cSearchTimerThread::AddModTimer(cTimer* Timer, int index, cSearchExt* searchExt, const cEvent* pEvent, int Prio, int Lifetime, char* Summary, uint timerMod)
{
- char *cmdbuf = NULL;
-
- 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 - (searchExt->MarginStart * 60);
- time_t stop = eStop + (searchExt->MarginStop * 60);
- int Flags = Timer->Flags();
- if (searchExt->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
-
- if (searchExt->action == searchTimerActionInactiveRecord)
- Flags &= ~tfActive;
-
- // already done the same timer?
- if (!EPGSearchConfig.TimerProgRepeat && index == 0 && TimersDone.InList(start, stop, pEvent, -1))
- {
- LogFile.Log(2,"skip timer for '%s~%s' (%s - %s); search timer: '%s' - already done", pEvent->Title(), pEvent->ShortText()?pEvent->ShortText():"", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), searchExt->search);
- return false;
- }
-
- strftime(bufStart, sizeof(bufStart), "%H%M", localtime_r(&start, &tm_r));
- strftime(bufEnd, sizeof(bufEnd), "%H%M", localtime_r(&stop, &tm_r));
-
- // add additional info
- char* tmpSummary = NULL;
- if (Summary)
- {
- tmpSummary = strdup(Summary);
- strreplace(tmpSummary, '\n', '|');
- }
- else
- tmpSummary = SummaryExtended(searchExt, Timer, pEvent);
- if (index==0)
- msprintf(&cmdbuf, "NEWT %d:%d:%s:%s:%s:%d:%d:%s:%s",
- Flags,
- Timer->Channel()->Number(),
- *Timer->PrintDay(start, Timer->WeekDays(), true),
- bufStart,
- bufEnd,
- Prio,
- Lifetime,
- Timer->File(),
- tmpSummary?tmpSummary:"");
- else
- msprintf(&cmdbuf, "MODT %d %d:%d:%s:%s:%s:%d:%d:%s:%s",
- index,
- Flags,
- Timer->Channel()->Number(),
- *Timer->PrintDay(start, Timer->WeekDays(), true),
- bufStart,
- bufEnd,
- Prio,
- Lifetime,
- Timer->File(),
- tmpSummary?tmpSummary:"");
-
- if (!SendViaSVDRP(cmdbuf))
- return false;
-
- if (gl_timerStatusMonitor) gl_timerStatusMonitor->SetConflictCheckAdvised();
-
- cTimerDone* timerdone = new cTimerDone(start, stop, pEvent, searchExt->ID);
- if (index==0)
- TimersDone.Add(timerdone);
- else
- TimersDone.Update(start, stop, pEvent, searchExt->ID, timerdone);
-
- if (EPGSearchConfig.sendMailOnSearchtimers)
- {
- if (index==0) // new
- mailNotifier.AddNewTimerNotification(pEvent->EventID(), pEvent->ChannelID());
- else
- mailNotifier.AddModTimerNotification(pEvent->EventID(), pEvent->ChannelID(), timerMod);
- }
- free(cmdbuf);
- if (tmpSummary) free(tmpSummary);
-
- return true;
+ char *cmdbuf = NULL;
+
+ 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 - (searchExt->MarginStart * 60);
+ time_t stop = eStop + (searchExt->MarginStop * 60);
+ int Flags = Timer->Flags();
+ if (searchExt->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
+
+ if (searchExt->action == searchTimerActionInactiveRecord)
+ Flags &= ~tfActive;
+
+ // already done the same timer?
+ if (!EPGSearchConfig.TimerProgRepeat && index == 0 && TimersDone.InList(start, stop, pEvent, -1)) {
+ LogFile.Log(2, "skip timer for '%s~%s' (%s - %s); search timer: '%s' - already done", pEvent->Title(), pEvent->ShortText() ? pEvent->ShortText() : "", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), searchExt->search);
+ return false;
+ }
+
+ strftime(bufStart, sizeof(bufStart), "%H%M", localtime_r(&start, &tm_r));
+ strftime(bufEnd, sizeof(bufEnd), "%H%M", localtime_r(&stop, &tm_r));
+
+ // add additional info
+ char* tmpSummary = NULL;
+ if (Summary) {
+ tmpSummary = strdup(Summary);
+ strreplace(tmpSummary, '\n', '|');
+ } else
+ tmpSummary = SummaryExtended(searchExt, Timer, pEvent);
+ if (index == 0)
+ msprintf(&cmdbuf, "NEWT %d:%d:%s:%s:%s:%d:%d:%s:%s",
+ Flags,
+ Timer->Channel()->Number(),
+ *Timer->PrintDay(start, Timer->WeekDays(), true),
+ bufStart,
+ bufEnd,
+ Prio,
+ Lifetime,
+ Timer->File(),
+ tmpSummary ? tmpSummary : "");
+ else
+ msprintf(&cmdbuf, "MODT %d %d:%d:%s:%s:%s:%d:%d:%s:%s",
+ index,
+ Flags,
+ Timer->Channel()->Number(),
+ *Timer->PrintDay(start, Timer->WeekDays(), true),
+ bufStart,
+ bufEnd,
+ Prio,
+ Lifetime,
+ Timer->File(),
+ tmpSummary ? tmpSummary : "");
+
+ if (!SendViaSVDRP(cmdbuf))
+ return false;
+
+ if (gl_timerStatusMonitor) gl_timerStatusMonitor->SetConflictCheckAdvised();
+
+ cTimerDone* timerdone = new cTimerDone(start, stop, pEvent, searchExt->ID);
+ if (index == 0)
+ TimersDone.Add(timerdone);
+ else
+ TimersDone.Update(start, stop, pEvent, searchExt->ID, timerdone);
+
+ if (EPGSearchConfig.sendMailOnSearchtimers) {
+ if (index == 0) // new
+ mailNotifier.AddNewTimerNotification(pEvent->EventID(), pEvent->ChannelID());
+ else
+ mailNotifier.AddModTimerNotification(pEvent->EventID(), pEvent->ChannelID(), timerMod);
+ }
+ free(cmdbuf);
+ if (tmpSummary) free(tmpSummary);
+
+ return true;
}
void cSearchTimerThread::RemoveTimer(const cTimer* t, const cEvent* e)
{
- if (!t) return;
- if (EPGSearchConfig.sendMailOnSearchtimers)
- mailNotifier.AddRemoveTimerNotification(t,e);
- if (!EPGSearchConfig.TimerProgRepeat)
- {
- cTimerDone * TimerDone = TimersDone.InList(t->StartTime(), t->StopTime(), e, -1);
- if (TimerDone)
- {
- cMutexLock TimersDoneLock(&TimersDone);
- TimersDone.Del(TimerDone);
- TimersDone.Save();
- }
- }
- DelTimer(t->Id());
+ if (!t) return;
+ if (EPGSearchConfig.sendMailOnSearchtimers)
+ mailNotifier.AddRemoveTimerNotification(t, e);
+ if (!EPGSearchConfig.TimerProgRepeat) {
+ cTimerDone * TimerDone = TimersDone.InList(t->StartTime(), t->StopTime(), e, -1);
+ if (TimerDone) {
+ cMutexLock TimersDoneLock(&TimersDone);
+ TimersDone.Del(TimerDone);
+ TimersDone.Save();
+ }
+ }
+ DelTimer(t->Id());
}
void cSearchTimerThread::DelRecording(int index)
{
- cString cmdbuf = cString::sprintf("DELR %d", index);
- LogFile.Log(2, "delete recording %d", index);
- SendViaSVDRP(cmdbuf);
+ cString cmdbuf = cString::sprintf("DELR %d", index);
+ LogFile.Log(2, "delete recording %d", index);
+ SendViaSVDRP(cmdbuf);
}
void cSearchTimerThread::CheckExpiredRecs()
{
- LogFile.Log(1, "check for expired recordings started");
- LOCK_RECORDINGS_WRITE;
- Recordings->SetExplicitModify();
- cList<cRecordingObj> DelRecordings;
- for (cRecording *recording = Recordings->First(); recording && m_Active; recording = Recordings->Next(recording))
- {
- LogFile.Log(3, "check recording %s from %s for expiration", recording->Name(), DAYDATETIME(recording->Start()));
- if (recording->Start() == 0)
- {
- LogFile.Log(2, "oops, recording %s has no start time, skipped", recording->Name());
- continue;
- }
- if (recording->IsEdited()) continue;
-
- if (!recording->Info()) continue;
- char* searchID = GetAuxValue(recording, "s-id");
- char* searchName = GetAuxValue(recording, "searchtimer");
- if (!searchName)
- searchName = GetAuxValue(recording, "search timer");
-
- if (!searchID || !searchName)
- {
- if (searchID) free(searchID);
- if (searchName) free(searchName);
- continue;
- }
- cSearchExt* search = SearchExts.GetSearchFromID(atoi(searchID));
- if (!search || strcmp(search->search, searchName) != 0)
- {
- if (searchID) free(searchID);
- if (searchName) free(searchName);
- continue;
- }
- free(searchID);
- free(searchName);
- LogFile.Log(3, "recording triggered from search timer %s", search->search);
- if (search->delAfterDays == 0) continue;
- time_t now = time(NULL);
-
- int daysBetween = int(double((now - recording->Start())) / (60*60*24));
- if (daysBetween >= search->delAfterDays)
- DelRecordings.Add(new cRecordingObj(recording, search));
- else
- LogFile.Log(3, "recording will expire in %d days, search timer %s", search->delAfterDays - daysBetween, search->search);
- }
- for (cRecordingObj *recordingObj = DelRecordings.First(); recordingObj && m_Active; recordingObj = DelRecordings.Next(recordingObj))
- {
- cRecording* recording = recordingObj->recording;
- cSearchExt* search = recordingObj->search;
- if (search->recordingsKeep > 0 && search->recordingsKeep >= search->GetCountRecordings())
- {
- LogFile.Log(1, "recording '%s' from %s expired, but will be kept, search timer %s", recording->Name(), DAYDATETIME(recording->Start()), recordingObj->search->search);
- continue;
- }
- LogFile.Log(1, "delete expired recording '%s' from %s, search timer %s", recording->Name(), DAYDATETIME(recording->Start()), recordingObj->search->search);
- cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
- if (!rc)
- {
- if (!recording->Delete())
- LogFile.Log(1, "error deleting recording!");
- else
- {
- Recordings->DelByName(recording->FileName());
- Recordings->SetModified();
- }
- }
- else
- LogFile.Log(1, "recording already in use by a timer!");
- }
- LogFile.Log(1, "check for expired recordings finished");
+ LogFile.Log(1, "check for expired recordings started");
+ LOCK_RECORDINGS_WRITE;
+ Recordings->SetExplicitModify();
+ cList<cRecordingObj> DelRecordings;
+ for (cRecording *recording = Recordings->First(); recording && m_Active; recording = Recordings->Next(recording)) {
+ LogFile.Log(3, "check recording %s from %s for expiration", recording->Name(), DAYDATETIME(recording->Start()));
+ if (recording->Start() == 0) {
+ LogFile.Log(2, "oops, recording %s has no start time, skipped", recording->Name());
+ continue;
+ }
+ if (recording->IsEdited()) continue;
+
+ if (!recording->Info()) continue;
+ char* searchID = GetAuxValue(recording, "s-id");
+ char* searchName = GetAuxValue(recording, "searchtimer");
+ if (!searchName)
+ searchName = GetAuxValue(recording, "search timer");
+
+ if (!searchID || !searchName) {
+ if (searchID) free(searchID);
+ if (searchName) free(searchName);
+ continue;
+ }
+ cSearchExt* search = SearchExts.GetSearchFromID(atoi(searchID));
+ if (!search || strcmp(search->search, searchName) != 0) {
+ if (searchID) free(searchID);
+ if (searchName) free(searchName);
+ continue;
+ }
+ free(searchID);
+ free(searchName);
+ LogFile.Log(3, "recording triggered from search timer %s", search->search);
+ if (search->delAfterDays == 0) continue;
+ time_t now = time(NULL);
+
+ int daysBetween = int(double((now - recording->Start())) / (60 * 60 * 24));
+ if (daysBetween >= search->delAfterDays)
+ DelRecordings.Add(new cRecordingObj(recording, search));
+ else
+ LogFile.Log(3, "recording will expire in %d days, search timer %s", search->delAfterDays - daysBetween, search->search);
+ }
+ for (cRecordingObj *recordingObj = DelRecordings.First(); recordingObj && m_Active; recordingObj = DelRecordings.Next(recordingObj)) {
+ cRecording* recording = recordingObj->recording;
+ cSearchExt* search = recordingObj->search;
+ if (search->recordingsKeep > 0 && search->recordingsKeep >= search->GetCountRecordings()) {
+ LogFile.Log(1, "recording '%s' from %s expired, but will be kept, search timer %s", recording->Name(), DAYDATETIME(recording->Start()), recordingObj->search->search);
+ continue;
+ }
+ LogFile.Log(1, "delete expired recording '%s' from %s, search timer %s", recording->Name(), DAYDATETIME(recording->Start()), recordingObj->search->search);
+ cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
+ if (!rc) {
+ if (!recording->Delete())
+ LogFile.Log(1, "error deleting recording!");
+ else {
+ Recordings->DelByName(recording->FileName());
+ Recordings->SetModified();
+ }
+ } else
+ LogFile.Log(1, "recording already in use by a timer!");
+ }
+ LogFile.Log(1, "check for expired recordings finished");
}
void cSearchTimerThread::ModifyManualTimer(const cEvent* event, const cTimer* timer, int bstart, int bstop)
{
- LogFile.Log(1,"modified manual timer %d for '%s~%s' (%s - %s)", timer->Id(), event->Title(), event->ShortText()?event->ShortText():"", GETDATESTRING(event), GETTIMESTRING(event));
-
- time_t start = event->StartTime() - bstart;
- time_t stop = event->EndTime() + bstop;
- struct tm tm_r_start;
- struct tm tm_r_stop;
- localtime_r(&start, &tm_r_start);
- localtime_r(&stop, &tm_r_stop);
- char daybuffer[DAYBUFFERSIZE];
- char startbuffer[DAYBUFFERSIZE];
- char stopbuffer[DAYBUFFERSIZE];
- strftime(daybuffer, DAYBUFFERSIZE, "%Y-%m-%d", &tm_r_start);
- strftime(startbuffer, DAYBUFFERSIZE, "%H%M", &tm_r_start);
- strftime(stopbuffer, DAYBUFFERSIZE, "%H%M", &tm_r_stop);
-
- char* cmdbuf = NULL;
- msprintf(&cmdbuf, "MODT %d %d:%d:%s:%s:%s:%d:%d:%s:%s",
- timer->Id(),
- timer->Flags(),
- timer->Channel()->Number(),
- daybuffer,
- startbuffer,
- stopbuffer,
- timer->Priority(),
- timer->Lifetime(),
- timer->File(),
- timer->Aux());
-
- if (EPGSearchConfig.sendMailOnSearchtimers)
- mailNotifier.AddModTimerNotification(event->EventID(), event->ChannelID());
-
- cTimerThread timerThread;
- timerThread.Init(cmdbuf);
- free(cmdbuf);
+ LogFile.Log(1, "modified manual timer %d for '%s~%s' (%s - %s)", timer->Id(), event->Title(), event->ShortText() ? event->ShortText() : "", GETDATESTRING(event), GETTIMESTRING(event));
+
+ time_t start = event->StartTime() - bstart;
+ time_t stop = event->EndTime() + bstop;
+ struct tm tm_r_start;
+ struct tm tm_r_stop;
+ localtime_r(&start, &tm_r_start);
+ localtime_r(&stop, &tm_r_stop);
+ char daybuffer[DAYBUFFERSIZE];
+ char startbuffer[DAYBUFFERSIZE];
+ char stopbuffer[DAYBUFFERSIZE];
+ strftime(daybuffer, DAYBUFFERSIZE, "%Y-%m-%d", &tm_r_start);
+ strftime(startbuffer, DAYBUFFERSIZE, "%H%M", &tm_r_start);
+ strftime(stopbuffer, DAYBUFFERSIZE, "%H%M", &tm_r_stop);
+
+ char* cmdbuf = NULL;
+ msprintf(&cmdbuf, "MODT %d %d:%d:%s:%s:%s:%d:%d:%s:%s",
+ timer->Id(),
+ timer->Flags(),
+ timer->Channel()->Number(),
+ daybuffer,
+ startbuffer,
+ stopbuffer,
+ timer->Priority(),
+ timer->Lifetime(),
+ timer->File(),
+ timer->Aux());
+
+ if (EPGSearchConfig.sendMailOnSearchtimers)
+ mailNotifier.AddModTimerNotification(event->EventID(), event->ChannelID());
+
+ cTimerThread timerThread;
+ timerThread.Init(cmdbuf);
+ free(cmdbuf);
}
void cSearchTimerThread::CheckManualTimers(void)
{
- LogFile.Log(1, "manual timer check started");
+ LogFile.Log(1, "manual timer check started");
LOCK_TIMERS_READ;
LOCK_SCHEDULES_READ;
- for (const cTimer *ti = Timers->First(); ti && m_Active; ti = Timers->Next(ti))
- {
- if (TriggeredFromSearchTimerID(ti) != -1) continue; // manual timer?
-
- if (TimerWasModified(ti))
- {
- LogFile.Log(2,"timer for '%s' (%s, channel %s) modified by user - won't be touched", ti->File(), DAYDATETIME(ti->StartTime()), CHANNELNAME(ti->Channel()));
- continue; // don't update timers modified by user
- }
-
- char* szbstart = GetAuxValue(ti, "bstart");
- int bstart = szbstart? atoi(szbstart) : 0;
- free(szbstart);
- char* szbstop = GetAuxValue(ti, "bstop");
- int bstop = szbstop? atoi(szbstop) : 0;
- free(szbstop);
-
- // how to check?
- char* updateMethod = GetAuxValue(ti, "update");
- if (updateMethod && atoi(updateMethod) == UPD_EVENTID) // by event ID?
- {
- // get the channels schedule
- const cSchedule* schedule = Schedules->GetSchedule(ti->Channel());
- if (schedule)
- {
- tEventID eventID = 0;
- char* szEventID = GetAuxValue(ti, "eventid");
- if (szEventID)
- eventID = atol(szEventID);
- LogFile.Log(3,"checking manual timer %d by event ID %u", ti->Id(), eventID);
- const cEvent* event = schedule->GetEvent(eventID);
- if (event)
- {
- if (event->StartTime() - bstart != ti->StartTime() || event->EndTime() + bstop != ti->StopTime())
- ModifyManualTimer(event, ti, bstart, bstop);
+ for (const cTimer *ti = Timers->First(); ti && m_Active; ti = Timers->Next(ti)) {
+ if (TriggeredFromSearchTimerID(ti) != -1) continue; // manual timer?
+
+ if (TimerWasModified(ti)) {
+ LogFile.Log(2, "timer for '%s' (%s, channel %s) modified by user - won't be touched", ti->File(), DAYDATETIME(ti->StartTime()), CHANNELNAME(ti->Channel()));
+ continue; // don't update timers modified by user
+ }
+
+ char* szbstart = GetAuxValue(ti, "bstart");
+ int bstart = szbstart ? atoi(szbstart) : 0;
+ free(szbstart);
+ char* szbstop = GetAuxValue(ti, "bstop");
+ int bstop = szbstop ? atoi(szbstop) : 0;
+ free(szbstop);
+
+ // how to check?
+ char* updateMethod = GetAuxValue(ti, "update");
+ if (updateMethod && atoi(updateMethod) == UPD_EVENTID) { // by event ID?
+ // get the channels schedule
+ const cSchedule* schedule = Schedules->GetSchedule(ti->Channel());
+ if (schedule) {
+ tEventID eventID = 0;
+ char* szEventID = GetAuxValue(ti, "eventid");
+ if (szEventID)
+ eventID = atol(szEventID);
+ LogFile.Log(3, "checking manual timer %d by event ID %u", ti->Id(), eventID);
+ const cEvent* event = schedule->GetEvent(eventID);
+ if (event) {
+ if (event->StartTime() - bstart != ti->StartTime() || event->EndTime() + bstop != ti->StopTime())
+ ModifyManualTimer(event, ti, bstart, bstop);
+ } else
+ LogFile.Log(1, "ooops - no event found with id %u for manual timer %d", eventID, ti->Id());
+
+ if (szEventID) free(szEventID);
}
- else
- LogFile.Log(1,"ooops - no event found with id %u for manual timer %d", eventID, ti->Id());
-
- if (szEventID) free(szEventID);
- }
- }
- if (updateMethod && atoi(updateMethod) == UPD_CHDUR) // by channel and time?
- {
- // get the channels schedule
- const cSchedule* schedule = Schedules->GetSchedule(ti->Channel());
- if (schedule)
- {
- // collect all events touching the old timer margins
- cSearchResults eventlist;
- for (const cEvent *testevent = schedule->Events()->First(); testevent; testevent = schedule->Events()->Next(testevent))
- {
- if (testevent->StartTime() < ti->StopTime() && testevent->EndTime() > ti->StartTime())
- eventlist.Add(new cSearchResult(testevent, (const cSearchExt*)NULL));
+ }
+ if (updateMethod && atoi(updateMethod) == UPD_CHDUR) { // by channel and time?
+ // get the channels schedule
+ const cSchedule* schedule = Schedules->GetSchedule(ti->Channel());
+ if (schedule) {
+ // collect all events touching the old timer margins
+ cSearchResults eventlist;
+ for (const cEvent *testevent = schedule->Events()->First(); testevent; testevent = schedule->Events()->Next(testevent)) {
+ if (testevent->StartTime() < ti->StopTime() && testevent->EndTime() > ti->StartTime())
+ eventlist.Add(new cSearchResult(testevent, (const cSearchExt*)NULL));
+ }
+ LogFile.Log(3, "checking manual timer %d by channel and time, found %d candidates", ti->Id(), eventlist.Count());
+ if (eventlist.Count() > 0) {
+ // choose the event with the best match by duration
+ long origlen = (ti->StopTime() - bstop) - (ti->StartTime() + bstart);
+ double maxweight = 0;
+ const cEvent* event = eventlist.First()->event;
+ for (cSearchResult* pResultObj = eventlist.First(); pResultObj; pResultObj = eventlist.Next(pResultObj)) {
+ const cEvent* testevent = pResultObj->event;
+ time_t start = (testevent->StartTime() < ti->StartTime()) ? ti->StartTime() : testevent->StartTime();
+ time_t stop = (testevent->EndTime() > ti->StopTime()) ? ti->StopTime() : testevent->EndTime();
+ double weight = double(stop - start) / double(testevent->EndTime() - testevent->StartTime());
+ LogFile.Log(3, "candidate '%s~%s' (%s - %s) timer match: %f, duration match: %f", testevent->Title(), testevent->ShortText() ? testevent->ShortText() : "", GETDATESTRING(testevent), GETTIMESTRING(testevent), weight, (double(testevent->EndTime() - testevent->StartTime()) / origlen));
+ if (weight > maxweight && (double(testevent->EndTime() - testevent->StartTime()) / origlen) >= 0.9) {
+ maxweight = weight;
+ event = testevent;
+ }
+ }
+ LogFile.Log(3, "selected candidate is '%s~%s' (%s - %s)", event->Title(), event->ShortText() ? event->ShortText() : "", GETDATESTRING(event), GETTIMESTRING(event));
+ if ((maxweight > 0 && event->StartTime() - bstart != ti->StartTime()) || (event->EndTime() + bstop != ti->StopTime()))
+ ModifyManualTimer(event, ti, bstart, bstop);
+ else if (maxweight <= 0)
+ LogFile.Log(3, "selected candidate is too bad");
+ } else
+ LogFile.Log(1, "ooops - no events found touching manual timer %d", ti->Id());
}
- LogFile.Log(3,"checking manual timer %d by channel and time, found %d candidates", ti->Id(), eventlist.Count());
- if (eventlist.Count() > 0)
- {
- // choose the event with the best match by duration
- long origlen = (ti->StopTime() - bstop) - (ti->StartTime() + bstart);
- double maxweight = 0;
- const cEvent* event = eventlist.First()->event;
- for (cSearchResult* pResultObj = eventlist.First(); pResultObj; pResultObj = eventlist.Next(pResultObj))
- {
- const cEvent* testevent = pResultObj->event;
- time_t start = (testevent->StartTime() < ti->StartTime()) ? ti->StartTime() : testevent->StartTime();
- time_t stop = (testevent->EndTime() > ti->StopTime()) ? ti->StopTime() : testevent->EndTime();
- double weight = double(stop - start) / double(testevent->EndTime() - testevent->StartTime());
- LogFile.Log(3,"candidate '%s~%s' (%s - %s) timer match: %f, duration match: %f", testevent->Title(), testevent->ShortText()?testevent->ShortText():"", GETDATESTRING(testevent), GETTIMESTRING(testevent), weight, (double(testevent->EndTime() - testevent->StartTime()) / origlen));
- if (weight > maxweight && (double(testevent->EndTime() - testevent->StartTime()) / origlen) >= 0.9)
- {
- maxweight = weight;
- event = testevent;
- }
- }
- LogFile.Log(3,"selected candidate is '%s~%s' (%s - %s)", event->Title(), event->ShortText()?event->ShortText():"", GETDATESTRING(event), GETTIMESTRING(event));
- if ((maxweight > 0 && event->StartTime() - bstart != ti->StartTime()) || (event->EndTime() + bstop != ti->StopTime()))
- ModifyManualTimer(event, ti, bstart, bstop);
- else if (maxweight <= 0)
- LogFile.Log(3,"selected candidate is too bad");
- }
- else
- LogFile.Log(1,"ooops - no events found touching manual timer %d", ti->Id());
- }
- if (updateMethod) free(updateMethod);
- }
- }
- LogFile.Log(1, "manual timer check finished");
+ if (updateMethod) free(updateMethod);
+ }
+ }
+ LogFile.Log(1, "manual timer check finished");
}
// check if EPG is present for the configured hours
void cSearchTimerThread::CheckEPGHours()
{
- if (EPGSearchConfig.checkEPGHours <= 0 ||
- (EPGSearchConfig.checkEPGWarnByOSD == 0 && EPGSearchConfig.checkEPGWarnByMail == 0) ||
- EPGSearchConfig.checkEPGchannelGroupNr <= 0)
- return;
-
- LogFile.Log(2,"check if relevant EPG exists for the next %d hours", EPGSearchConfig.checkEPGHours);
- cChannelGroup* channelGroup = ChannelGroups.Get(EPGSearchConfig.checkEPGchannelGroupNr-1); // not zero-based!
- if (!channelGroup)
- {
- LogFile.Log(1,"channel group with index %d does not exist!", EPGSearchConfig.checkEPGchannelGroupNr);
- return;
+ if (EPGSearchConfig.checkEPGHours <= 0 ||
+ (EPGSearchConfig.checkEPGWarnByOSD == 0 && EPGSearchConfig.checkEPGWarnByMail == 0) ||
+ EPGSearchConfig.checkEPGchannelGroupNr <= 0)
+ return;
+
+ LogFile.Log(2, "check if relevant EPG exists for the next %d hours", EPGSearchConfig.checkEPGHours);
+ cChannelGroup* channelGroup = ChannelGroups.Get(EPGSearchConfig.checkEPGchannelGroupNr - 1); // not zero-based!
+ if (!channelGroup) {
+ LogFile.Log(1, "channel group with index %d does not exist!", EPGSearchConfig.checkEPGchannelGroupNr);
+ return;
}
- LogFile.Log(2,"checking channel group '%s'", channelGroup->name);
+ LogFile.Log(2, "checking channel group '%s'", channelGroup->name);
- time_t checkTime = time(NULL) + EPGSearchConfig.checkEPGHours * 60 * 60;
+ time_t checkTime = time(NULL) + EPGSearchConfig.checkEPGHours * 60 * 60;
LOCK_SCHEDULES_READ;
- cChannelGroup channelsWithSmallEPG;
- cChannelGroupItem* channelInGroup = channelGroup->channels.First();
- while (channelInGroup)
- {
- const cChannel* channel = channelInGroup->channel;
- // get the channels schedule
- const cSchedule* schedule = Schedules->GetSchedule(channel);
- if (!schedule || !schedule->GetEventAround(checkTime))
- {
- LogFile.Log(3,"less than %d hours of EPG for channel %s!", EPGSearchConfig.checkEPGHours, channel->Name());
- cChannelGroupItem* channelitem = new cChannelGroupItem(channel);
- channelsWithSmallEPG.channels.Add(channelitem);
- }
- channelInGroup = channelGroup->channels.Next(channelInGroup);
+ cChannelGroup channelsWithSmallEPG;
+ cChannelGroupItem* channelInGroup = channelGroup->channels.First();
+ while (channelInGroup) {
+ const cChannel* channel = channelInGroup->channel;
+ // get the channels schedule
+ const cSchedule* schedule = Schedules->GetSchedule(channel);
+ if (!schedule || !schedule->GetEventAround(checkTime)) {
+ LogFile.Log(3, "less than %d hours of EPG for channel %s!", EPGSearchConfig.checkEPGHours, channel->Name());
+ cChannelGroupItem* channelitem = new cChannelGroupItem(channel);
+ channelsWithSmallEPG.channels.Add(channelitem);
+ }
+ channelInGroup = channelGroup->channels.Next(channelInGroup);
}
- // create a string list of the channels found
- if (channelsWithSmallEPG.channels.Count() > 0)
- {
- string sBuffer;
- channelInGroup = channelsWithSmallEPG.channels.First();
- while (channelInGroup)
- {
- const cChannel* channel = channelInGroup->channel;
- if (channel)
- sBuffer += " " + string(channel->ShortName(true));
- channelInGroup = channelsWithSmallEPG.channels.Next(channelInGroup);
- }
-
-
- if (EPGSearchConfig.checkEPGWarnByOSD)
- {
- cString msgfmt = cString::sprintf(tr("small EPG content on:%s"), sBuffer.c_str());
- SendMsg(msgfmt, false, 0, mtWarning);
- }
- if (EPGSearchConfig.checkEPGWarnByMail)
- {
- cString msgfmt = cString::sprintf(tr("small EPG content on:%s"), sBuffer.c_str());
- cMailNotifier M(string(tr("VDR EPG check warning")), string(msgfmt));
- }
+ // create a string list of the channels found
+ if (channelsWithSmallEPG.channels.Count() > 0) {
+ string sBuffer;
+ channelInGroup = channelsWithSmallEPG.channels.First();
+ while (channelInGroup) {
+ const cChannel* channel = channelInGroup->channel;
+ if (channel)
+ sBuffer += " " + string(channel->ShortName(true));
+ channelInGroup = channelsWithSmallEPG.channels.Next(channelInGroup);
+ }
+
+
+ if (EPGSearchConfig.checkEPGWarnByOSD) {
+ cString msgfmt = cString::sprintf(tr("small EPG content on:%s"), sBuffer.c_str());
+ SendMsg(msgfmt, false, 0, mtWarning);
+ }
+ if (EPGSearchConfig.checkEPGWarnByMail) {
+ cString msgfmt = cString::sprintf(tr("small EPG content on:%s"), sBuffer.c_str());
+ cMailNotifier M(string(tr("VDR EPG check warning")), string(msgfmt));
+ }
}
- LogFile.Log(2,"check for relevant EPG finished - %d channels with small EPG content", channelsWithSmallEPG.channels.Count());
+ LogFile.Log(2, "check for relevant EPG finished - %d channels with small EPG content", channelsWithSmallEPG.channels.Count());
}
diff --git a/searchtimer_thread.h b/searchtimer_thread.h
index ddf8b85..ebba7cf 100644
--- a/searchtimer_thread.h
+++ b/searchtimer_thread.h
@@ -32,32 +32,36 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
class cPluginEpgsearch;
// --- cRecordingObj --------------------------------------------------------
-class cRecordingObj : public cListObject {
+class cRecordingObj : public cListObject
+{
public:
cRecording* recording;
cSearchExt* search;
public:
cRecordingObj(cRecording* r, cSearchExt* s) : recording(r), search(s) {}
- ~cRecordingObj() { recording = NULL;} // do not delete anything!
+ ~cRecordingObj() {
+ recording = NULL; // do not delete anything!
+ }
};
// --- cSearchTimerThread----------------------------------------------------
-class cSearchTimerThread: public cThread {
- private:
+class cSearchTimerThread: public cThread
+{
+private:
bool m_Active;
time_t m_lastUpdate;
cPluginEpgsearch* m_plugin;
cMailUpdateNotifier mailNotifier;
cCondWait Wait;
- protected:
+protected:
virtual void Action(void);
bool AddModTimer(cTimer* Timer, int, cSearchExt*, const cEvent*, int Prio, int Lifetime, char* Summary = NULL, uint timerMod = tmNoChange);
void RemoveTimer(const cTimer* Timer, const cEvent* Event = NULL);
void Stop(void);
bool NeedUpdate();
bool TimerWasModified(const cTimer* t);
- public:
+public:
static cSearchResults announceList;
static char* SummaryExtended(cSearchExt* searchExt, const cTimer* Timer, const cEvent* pEvent);
static cSearchTimerThread *m_Instance;
diff --git a/services.c b/services.c
index 617c9b3..2013a38 100644
--- a/services.c
+++ b/services.c
@@ -40,301 +40,281 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
std::list<std::string> cEpgsearchServiceHandler::SearchTimerList()
{
- std::list<std::string> list;
- cMutexLock SearchExtsLock(&SearchExts);
- for (int i = 0; i < SearchExts.Count(); i++)
- {
- cSearchExt* search = SearchExts.Get(i);
- if (search)
- list.push_back(search->ToText());
- }
- return list;
+ std::list<std::string> list;
+ cMutexLock SearchExtsLock(&SearchExts);
+ for (int i = 0; i < SearchExts.Count(); i++) {
+ cSearchExt* search = SearchExts.Get(i);
+ if (search)
+ list.push_back(search->ToText());
+ }
+ return list;
}
int cEpgsearchServiceHandler::AddSearchTimer(const std::string& settings)
{
- cSearchExt* search = new cSearchExt;
- if (search->Parse(settings.c_str()))
- {
- search->ID = SearchExts.GetNewID();
- LogFile.Log(1,"added search '%s' (%d) via service interface", 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((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
- return search->ID;
- }
- else
- {
- LogFile.Log(1,"error adding '%s' via service interface", search->search);
- delete search;
- return -1;
- }
+ cSearchExt* search = new cSearchExt;
+ if (search->Parse(settings.c_str())) {
+ search->ID = SearchExts.GetNewID();
+ LogFile.Log(1, "added search '%s' (%d) via service interface", 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((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
+ return search->ID;
+ } else {
+ LogFile.Log(1, "error adding '%s' via service interface", search->search);
+ delete search;
+ return -1;
+ }
}
bool cEpgsearchServiceHandler::ModSearchTimer(const std::string& settings)
{
- cSearchExt Search;
- if (Search.Parse(settings.c_str()))
- {
- cSearchExt *searchTemp = SearchExts.GetSearchFromID(Search.ID);
- if (searchTemp)
- {
- searchTemp->Parse(settings.c_str());
- LogFile.Log(1,"modified search '%s' (%d) via service interface", 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 true;
- }
- }
- else
- {
- LogFile.Log(1,"error modifying '%s' via service interface", settings.c_str());
- }
- return false;
+ cSearchExt Search;
+ if (Search.Parse(settings.c_str())) {
+ cSearchExt *searchTemp = SearchExts.GetSearchFromID(Search.ID);
+ if (searchTemp) {
+ searchTemp->Parse(settings.c_str());
+ LogFile.Log(1, "modified search '%s' (%d) via service interface", 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 true;
+ }
+ } else {
+ LogFile.Log(1, "error modifying '%s' via service interface", settings.c_str());
+ }
+ return false;
}
bool cEpgsearchServiceHandler::DelSearchTimer(int ID)
{
- cSearchExt *search = SearchExts.GetSearchFromID(ID);
- if (search)
- {
- LogFile.Log(1,"search '%s' deleted via service interface", search->search);
- cMutexLock SearchExtsLock(&SearchExts);
- SearchExts.Del(search);
- SearchExts.Save();
- RecsDone.RemoveSearchID(ID);
- return true;
- }
- else
- LogFile.Log(1,"error deleting search with id '%d' via service interface", ID);
- return false;
+ cSearchExt *search = SearchExts.GetSearchFromID(ID);
+ if (search) {
+ LogFile.Log(1, "search '%s' deleted via service interface", search->search);
+ cMutexLock SearchExtsLock(&SearchExts);
+ SearchExts.Del(search);
+ SearchExts.Save();
+ RecsDone.RemoveSearchID(ID);
+ return true;
+ } else
+ LogFile.Log(1, "error deleting search with id '%d' via service interface", ID);
+ return false;
}
std::list<std::string> cEpgsearchServiceHandler::TranslateResults(cSearchResults* pCompleteSearchResults)
{
- std::list<std::string> list;
-
- if (pCompleteSearchResults)
- {
- // transfer to result list
- 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];
-
- 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));
-
- eTimerMatch timerMatch;
- bool hasTimer = false;
- LOCK_TIMERS_READ;
- if (Timers->GetMatch(pEvent, &timerMatch))
- hasTimer = (timerMatch == tmFull);
-
- 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);
-
- std::string title = pEvent->Title()?ReplaceAll(pEvent->Title(), "|", "!^pipe!^"):"";
- title = ReplaceAll(title, ":", "|");
- std::string shorttext = pEvent->ShortText()?ReplaceAll(pEvent->ShortText(), "|", "!^pipe!^"):"";
- shorttext = ReplaceAll(shorttext, ":", "|");
- std::string description = pEvent->Description()?ReplaceAll(pEvent->Description(), "|", "!^pipe!^"):"";
- description = ReplaceAll(description, ":", "|");
-
- cString cmdbuf = cString::sprintf("%d:%u:%s:%s:%s:%ld:%ld:%s:%ld:%ld:%s:%d",
- result->search->ID,
- pEvent->EventID(),
- title.c_str(),
- shorttext.c_str(),
- description.c_str(),
- pEvent->StartTime(),
- pEvent->EndTime(),
- CHANNELSTRING(channel),
- timerMode>0?start:-1,
- timerMode>0?stop:-1,
- timerMode>0?result->search->BuildFile(pEvent):"",
- timerMode);
-
- list.push_back(*cmdbuf);
-
- delete(Timer);
- result = pCompleteSearchResults->Next(result);
- }
- }
- return list;
+ std::list<std::string> list;
+
+ if (pCompleteSearchResults) {
+ // transfer to result list
+ 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];
+
+ 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));
+
+ eTimerMatch timerMatch;
+ bool hasTimer = false;
+ LOCK_TIMERS_READ;
+ if (Timers->GetMatch(pEvent, &timerMatch))
+ hasTimer = (timerMatch == tmFull);
+
+ 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);
+
+ std::string title = pEvent->Title() ? ReplaceAll(pEvent->Title(), "|", "!^pipe!^") : "";
+ title = ReplaceAll(title, ":", "|");
+ std::string shorttext = pEvent->ShortText() ? ReplaceAll(pEvent->ShortText(), "|", "!^pipe!^") : "";
+ shorttext = ReplaceAll(shorttext, ":", "|");
+ std::string description = pEvent->Description() ? ReplaceAll(pEvent->Description(), "|", "!^pipe!^") : "";
+ description = ReplaceAll(description, ":", "|");
+
+ cString cmdbuf = cString::sprintf("%d:%u:%s:%s:%s:%ld:%ld:%s:%ld:%ld:%s:%d",
+ result->search->ID,
+ pEvent->EventID(),
+ title.c_str(),
+ shorttext.c_str(),
+ description.c_str(),
+ pEvent->StartTime(),
+ pEvent->EndTime(),
+ CHANNELSTRING(channel),
+ timerMode > 0 ? start : -1,
+ timerMode > 0 ? stop : -1,
+ timerMode > 0 ? result->search->BuildFile(pEvent) : "",
+ timerMode);
+
+ list.push_back(*cmdbuf);
+
+ delete(Timer);
+ result = pCompleteSearchResults->Next(result);
+ }
+ }
+ return list;
}
std::list<std::string> cEpgsearchServiceHandler::QuerySearchTimer(int ID)
{
- std::list<std::string> list;
+ std::list<std::string> list;
- cSearchResults* pCompleteSearchResults = NULL;
- cSearchExt* search = SearchExts.GetSearchFromID(ID);
- if (!search) return list;
+ cSearchResults* pCompleteSearchResults = NULL;
+ cSearchExt* search = SearchExts.GetSearchFromID(ID);
+ if (!search) return list;
- pCompleteSearchResults = search->Run();
- list = TranslateResults(pCompleteSearchResults);
- if (pCompleteSearchResults) delete pCompleteSearchResults;
- return list;
+ pCompleteSearchResults = search->Run();
+ list = TranslateResults(pCompleteSearchResults);
+ if (pCompleteSearchResults) delete pCompleteSearchResults;
+ return list;
}
std::list<std::string> cEpgsearchServiceHandler::QuerySearch(std::string query)
{
- std::list<std::string> list;
-
- cSearchExt* temp_SearchExt = new cSearchExt;
- if (temp_SearchExt->Parse(query.c_str()))
- {
- cSearchResults* pCompleteSearchResults = temp_SearchExt->Run();
- list = TranslateResults(pCompleteSearchResults);
- if (pCompleteSearchResults) delete pCompleteSearchResults;
- }
- delete temp_SearchExt;
- return list;
+ std::list<std::string> list;
+
+ cSearchExt* temp_SearchExt = new cSearchExt;
+ if (temp_SearchExt->Parse(query.c_str())) {
+ cSearchResults* pCompleteSearchResults = temp_SearchExt->Run();
+ list = TranslateResults(pCompleteSearchResults);
+ if (pCompleteSearchResults) delete pCompleteSearchResults;
+ }
+ delete temp_SearchExt;
+ return list;
}
std::list<std::string> cEpgsearchServiceHandler::ExtEPGInfoList()
{
- std::list<std::string> list;
- for (int i = 0; i < SearchExtCats.Count(); i++)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.Get(i);
- if (SearchExtCat)
- list.push_back(SearchExtCat->ToText());
- }
- return list;
+ std::list<std::string> list;
+ for (int i = 0; i < SearchExtCats.Count(); i++) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.Get(i);
+ if (SearchExtCat)
+ list.push_back(SearchExtCat->ToText());
+ }
+ return list;
}
std::list<std::string> cEpgsearchServiceHandler::ChanGrpList()
{
- std::list<std::string> list;
- for (int i = 0; i < ChannelGroups.Count(); i++)
- {
- cChannelGroup *changrp = ChannelGroups.Get(i);
- if (changrp)
- list.push_back(changrp->ToText());
- }
- return list;
+ std::list<std::string> list;
+ for (int i = 0; i < ChannelGroups.Count(); i++) {
+ cChannelGroup *changrp = ChannelGroups.Get(i);
+ if (changrp)
+ list.push_back(changrp->ToText());
+ }
+ return list;
}
std::list<std::string> cEpgsearchServiceHandler::BlackList()
{
- std::list<std::string> list;
- cMutexLock BlacklistLock(&Blacklists);
-
- for (int i = 0; i < Blacklists.Count(); i++)
- {
- cBlacklist* blacklist = Blacklists.Get(i);
- if (blacklist)
- list.push_back(blacklist->ToText());
- }
- return list;
+ std::list<std::string> list;
+ cMutexLock BlacklistLock(&Blacklists);
+
+ for (int i = 0; i < Blacklists.Count(); i++) {
+ cBlacklist* blacklist = Blacklists.Get(i);
+ if (blacklist)
+ list.push_back(blacklist->ToText());
+ }
+ return list;
}
std::set<std::string> cEpgsearchServiceHandler::DirectoryList()
{
- cMenuDirSelect::CreateDirSet();
- return cMenuDirSelect::directorySet;
+ cMenuDirSelect::CreateDirSet();
+ return cMenuDirSelect::directorySet;
}
std::string cEpgsearchServiceHandler::ReadSetupValue(const std::string& entry)
{
- if (entry == "DefPriority") return NumToString(EPGSearchConfig.DefPriority);
- if (entry == "DefLifetime") return NumToString(EPGSearchConfig.DefLifetime);
- if (entry == "DefMarginStart") return NumToString(EPGSearchConfig.DefMarginStart);
- if (entry == "DefMarginStop") return NumToString(EPGSearchConfig.DefMarginStop);
- return "";
+ if (entry == "DefPriority") return NumToString(EPGSearchConfig.DefPriority);
+ if (entry == "DefLifetime") return NumToString(EPGSearchConfig.DefLifetime);
+ if (entry == "DefMarginStart") return NumToString(EPGSearchConfig.DefMarginStart);
+ if (entry == "DefMarginStop") return NumToString(EPGSearchConfig.DefMarginStop);
+ return "";
}
bool cEpgsearchServiceHandler::WriteSetupValue(const std::string& entry, const std::string& value)
{
- return true;
+ return true;
}
std::list<std::string> cEpgsearchServiceHandler::TimerConflictList(bool relOnly)
{
- std::list<std::string> list;
- cConflictCheck conflictCheck;
- 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;
-
- 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();
- list.push_back(conflline.str());
- }
- }
-
- // set advised to false after an external conflict check
- if (gl_timerStatusMonitor) gl_timerStatusMonitor->SetConflictCheckAdvised(false);
-
- return list;
+ std::list<std::string> list;
+ cConflictCheck conflictCheck;
+ 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;
+
+ 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();
+ list.push_back(conflline.str());
+ }
+ }
+
+ // set advised to false after an external conflict check
+ if (gl_timerStatusMonitor) gl_timerStatusMonitor->SetConflictCheckAdvised(false);
+
+ return list;
}
bool cEpgsearchServiceHandler::IsConflictCheckAdvised()
{
- return gl_timerStatusMonitor?gl_timerStatusMonitor->ConflictCheckAdvised():false;
+ return gl_timerStatusMonitor ? gl_timerStatusMonitor->ConflictCheckAdvised() : false;
}
std::set<std::string> cEpgsearchServiceHandler::ShortDirectoryList()
{
- cMenuDirSelect::CreateDirSet(false);
- return cMenuDirSelect::directorySet;
+ cMenuDirSelect::CreateDirSet(false);
+ return cMenuDirSelect::directorySet;
}
std::string cEpgsearchServiceHandler::Evaluate(const std::string& expr, const cEvent* event)
{
- if (!event) return expr;
- cVarExpr varExpr(expr);
- return varExpr.Evaluate(event);
+ if (!event) return expr;
+ cVarExpr varExpr(expr);
+ return varExpr.Evaluate(event);
}
diff --git a/services.h b/services.h
index 2669da4..f6fedd8 100644
--- a/services.h
+++ b/services.h
@@ -31,172 +31,160 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include <vdr/osdbase.h>
// Data structure for service "Epgsearch-search-v1.0"
-struct Epgsearch_search_v1_0
-{
+struct Epgsearch_search_v1_0 {
// in
- char* query; // search term
- int mode; // search mode (0=phrase, 1=and, 2=or, 3=regular expression)
- int channelNr; // channel number to search in (0=any)
- bool useTitle; // search in title
- bool useSubTitle; // search in subtitle
- bool useDescription; // search in description
+ char* query; // search term
+ int mode; // search mode (0=phrase, 1=and, 2=or, 3=regular expression)
+ int channelNr; // channel number to search in (0=any)
+ bool useTitle; // search in title
+ bool useSubTitle; // search in subtitle
+ bool useDescription; // search in description
// out
- cOsdMenu* pResultMenu; // pointer to the menu of results
+ cOsdMenu* pResultMenu; // pointer to the menu of results
};
// Data structure for service "Epgsearch-exttimeredit-v1.0"
-struct Epgsearch_exttimeredit_v1_0
-{
+struct Epgsearch_exttimeredit_v1_0 {
// in
- cTimer* timer; // pointer to the timer to edit
- bool bNew; // flag that indicates, if this is a new timer or an existing one
- const cEvent* event; // pointer to the event corresponding to this timer (may be NULL)
+ cTimer* timer; // pointer to the timer to edit
+ bool bNew; // flag that indicates, if this is a new timer or an existing one
+ const cEvent* event; // pointer to the event corresponding to this timer (may be NULL)
// out
- cOsdMenu* pTimerMenu; // pointer to the menu of results
+ cOsdMenu* pTimerMenu; // pointer to the menu of results
};
// Data structure for service "Epgsearch-enablesearchtimers-v1.0"
-struct Epgsearch_enablesearchtimers_v1_0
-{
+struct Epgsearch_enablesearchtimers_v1_0 {
// in
- bool enable; // enable search timer thread?
+ bool enable; // enable search timer thread?
};
// Data structure for service "Epgsearch-updatesearchtimers-v1.0"
-struct Epgsearch_updatesearchtimers_v1_0
-{
+struct Epgsearch_updatesearchtimers_v1_0 {
// in
- bool showMessage; // inform via osd when finished?
+ bool showMessage; // inform via osd when finished?
};
// Data structure for service "Epgsearch-osdmessage-v1.0"
-struct Epgsearch_osdmessage_v1_0
-{
+struct Epgsearch_osdmessage_v1_0 {
// in
- char* message; // the message to display
- eMessageType type;
+ char* message; // the message to display
+ eMessageType type;
};
// Data structure for service "EpgsearchMenu-v1.0"
-struct EpgSearchMenu_v1_0
-{
+struct EpgSearchMenu_v1_0 {
// in
// out
- cOsdMenu* Menu; // pointer to the menu
+ cOsdMenu* Menu; // pointer to the menu
};
// Data structure for service "Epgsearch-lastconflictinfo-v1.0"
-struct Epgsearch_lastconflictinfo_v1_0
-{
+struct Epgsearch_lastconflictinfo_v1_0 {
// in
// out
- time_t nextConflict; // next conflict date, 0 if none
- int relevantConflicts; // number of relevant conflicts
- int totalConflicts; // total number of conflicts
+ time_t nextConflict; // next conflict date, 0 if none
+ int relevantConflicts; // number of relevant conflicts
+ int totalConflicts; // total number of conflicts
};
// Data structure for service "Epgsearch-searchresults-v1.0"
-struct Epgsearch_searchresults_v1_0
-{
+struct Epgsearch_searchresults_v1_0 {
// in
- char* query; // search term
- int mode; // search mode (0=phrase, 1=and, 2=or, 3=regular expression)
- int channelNr; // channel number to search in (0=any)
- bool useTitle; // search in title
- bool useSubTitle; // search in subtitle
- bool useDescription; // search in description
+ char* query; // search term
+ int mode; // search mode (0=phrase, 1=and, 2=or, 3=regular expression)
+ int channelNr; // channel number to search in (0=any)
+ bool useTitle; // search in title
+ bool useSubTitle; // search in subtitle
+ bool useDescription; // search in description
// out
- class cServiceSearchResult : public cListObject
- {
- public:
- const cEvent* event;
- cServiceSearchResult(const cEvent* Event) : event(Event) {}
- };
+ class cServiceSearchResult : public cListObject
+ {
+ public:
+ const cEvent* event;
+ cServiceSearchResult(const cEvent* Event) : event(Event) {}
+ };
- cList<cServiceSearchResult>* pResultList; // pointer to the results
+ cList<cServiceSearchResult>* pResultList; // pointer to the results
};
// Data structure for service "Epgsearch-switchtimer-v1.0"
-struct Epgsearch_switchtimer_v1_0
-{
+struct Epgsearch_switchtimer_v1_0 {
// in
- const cEvent* event;
- int mode; // mode (0=query existence, 1=add/modify, 2=delete)
+ const cEvent* event;
+ int mode; // mode (0=query existence, 1=add/modify, 2=delete)
// in/out
- int switchMinsBefore;
- int announceOnly;
+ int switchMinsBefore;
+ int announceOnly;
// out
- bool success; // result
+ bool success; // result
};
// Data structures for service "Epgsearch-services-v1.0"
class cServiceHandler
{
- public:
- virtual std::list<std::string> SearchTimerList() = 0;
- // returns a list of search timer entries in the same format as used in epgsearch.conf
- virtual int AddSearchTimer(const std::string&) = 0;
- // adds a new search timer and returns its ID (-1 on error)
- virtual bool ModSearchTimer(const std::string&) = 0;
- // edits an existing search timer and returns success
- virtual bool DelSearchTimer(int) = 0;
- // deletes search timer with given ID and returns success
- virtual std::list<std::string> QuerySearchTimer(int) = 0;
- // returns the search result of the searchtimer with given ID in the same format as used in SVDRP command 'QRYS' (->MANUAL)
- virtual std::list<std::string> QuerySearch(std::string) = 0;
- // returns the search result of the searchtimer with given settings in the same format as used in SVDRP command 'QRYS' (->MANUAL)
- virtual std::list<std::string> ExtEPGInfoList() = 0;
- // returns a list of extended EPG categories in the same format as used in epgsearchcats.conf
- virtual std::list<std::string> ChanGrpList() = 0;
- // returns a list of channel groups maintained by epgsearch
- virtual std::list<std::string> BlackList() = 0;
- // returns a list of blacklists in the same format as used in epgsearchblacklists.conf
- virtual std::set<std::string> DirectoryList() = 0;
- // List of all recording directories used in recordings, timers, search timers or in epgsearchdirs.conf
- virtual ~cServiceHandler() {}
- // Read a setup value
- virtual std::string ReadSetupValue(const std::string& entry) = 0;
- // Write a setup value
- virtual bool WriteSetupValue(const std::string& entry, const std::string& value) = 0;
+public:
+ virtual std::list<std::string> SearchTimerList() = 0;
+ // returns a list of search timer entries in the same format as used in epgsearch.conf
+ virtual int AddSearchTimer(const std::string&) = 0;
+ // adds a new search timer and returns its ID (-1 on error)
+ virtual bool ModSearchTimer(const std::string&) = 0;
+ // edits an existing search timer and returns success
+ virtual bool DelSearchTimer(int) = 0;
+ // deletes search timer with given ID and returns success
+ virtual std::list<std::string> QuerySearchTimer(int) = 0;
+ // returns the search result of the searchtimer with given ID in the same format as used in SVDRP command 'QRYS' (->MANUAL)
+ virtual std::list<std::string> QuerySearch(std::string) = 0;
+ // returns the search result of the searchtimer with given settings in the same format as used in SVDRP command 'QRYS' (->MANUAL)
+ virtual std::list<std::string> ExtEPGInfoList() = 0;
+ // returns a list of extended EPG categories in the same format as used in epgsearchcats.conf
+ virtual std::list<std::string> ChanGrpList() = 0;
+ // returns a list of channel groups maintained by epgsearch
+ virtual std::list<std::string> BlackList() = 0;
+ // returns a list of blacklists in the same format as used in epgsearchblacklists.conf
+ virtual std::set<std::string> DirectoryList() = 0;
+ // List of all recording directories used in recordings, timers, search timers or in epgsearchdirs.conf
+ virtual ~cServiceHandler() {}
+ // Read a setup value
+ virtual std::string ReadSetupValue(const std::string& entry) = 0;
+ // Write a setup value
+ virtual bool WriteSetupValue(const std::string& entry, const std::string& value) = 0;
};
-struct Epgsearch_services_v1_0
-{
+struct Epgsearch_services_v1_0 {
// in/out
- std::auto_ptr<cServiceHandler> handler;
+ std::auto_ptr<cServiceHandler> handler;
};
// Data structures for service "Epgsearch-services-v1.1"
class cServiceHandler_v1_1 : public cServiceHandler
{
- public:
- // Get timer conflicts
- virtual std::list<std::string> TimerConflictList(bool relOnly=false) = 0;
- // Check if a conflict check is advised
- virtual bool IsConflictCheckAdvised() = 0;
+public:
+ // Get timer conflicts
+ virtual std::list<std::string> TimerConflictList(bool relOnly = false) = 0;
+ // Check if a conflict check is advised
+ virtual bool IsConflictCheckAdvised() = 0;
};
-struct Epgsearch_services_v1_1
-{
+struct Epgsearch_services_v1_1 {
// in/out
- std::auto_ptr<cServiceHandler_v1_1> handler;
+ std::auto_ptr<cServiceHandler_v1_1> handler;
};
// Data structures for service "Epgsearch-services-v1.2"
class cServiceHandler_v1_2 : public cServiceHandler_v1_1
{
- public:
- // List of all recording directories used in recordings, timers (and optionally search timers or in epgsearchdirs.conf)
- virtual std::set<std::string> ShortDirectoryList() = 0;
- // Evaluate an expression against an event
- virtual std::string Evaluate(const std::string& expr, const cEvent* event) = 0;
+public:
+ // List of all recording directories used in recordings, timers (and optionally search timers or in epgsearchdirs.conf)
+ virtual std::set<std::string> ShortDirectoryList() = 0;
+ // Evaluate an expression against an event
+ virtual std::string Evaluate(const std::string& expr, const cEvent* event) = 0;
};
-struct Epgsearch_services_v1_2
-{
+struct Epgsearch_services_v1_2 {
// in/out
- std::auto_ptr<cServiceHandler_v1_2> handler;
+ std::auto_ptr<cServiceHandler_v1_2> handler;
};
#endif
diff --git a/svdrpclient.h b/svdrpclient.h
index e9533fe..5e36722 100644
--- a/svdrpclient.h
+++ b/svdrpclient.h
@@ -31,115 +31,103 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#define SVDRPDISCONNECT 221
#define CMDSUCCESS 250
-namespace epgsSVDRP {
+namespace epgsSVDRP
+{
-class cSVDRPClient {
- private:
+class cSVDRPClient
+{
+private:
int sock;
public:
bool bConnected;
- cSVDRPClient()
- {
- bConnected = false;
- sock = socket(PF_INET, SOCK_STREAM, 0);
- if (sock < 0)
- {
- LogFile.eSysLog("error creating socket!");
- return;
- }
-
- struct sockaddr_in AdrSock;
- AdrSock.sin_family = AF_INET;
- AdrSock.sin_port = htons(EPGSearchConfig.SVDRPPort);
- inet_aton("127.0.0.1", &AdrSock.sin_addr);
-
- if (connect(sock, (struct sockaddr*)&AdrSock, sizeof(AdrSock)) == -1)
- {
- LogFile.eSysLog("error connecting to socket!");
- return;
- }
- bConnected = (Receive() == SVDRPCONNECT);
- if (!bConnected)
- LogFile.eSysLog("EPGSearch: could not connect to VDR!");
- }
-
- ~cSVDRPClient()
- {
- if (sock >= 0)
- close(sock);
- }
-
- bool SendCmd(const char* cmd)
- {
- if (!bConnected)
- return false;
-
- cString szCmd = cString::sprintf("%s\r\n", cmd);
- Send(*szCmd);
- bool cmdret = (Receive() == CMDSUCCESS);
-
- szCmd = cString::sprintf("QUIT\r\n");
- Send(szCmd);
-
- long rc = 0;
- if ((rc = Receive()) != SVDRPDISCONNECT)
- LogFile.eSysLog("could not disconnect (%ld)!", rc);
-
- close(sock);
- sock = -1;
- return cmdret;
- }
- bool Send(const char* szSend)
- {
- int length = strlen(szSend);
- int sent = 0;
- do
- {
- sent += send(sock, szSend + sent, length - sent, 0);
- if( sent < 0 )
- {
- LogFile.eSysLog("error sending command!");
- return false;
- }
- }
- while ( sent < length );
- return true;
- }
- long Receive()
- {
- char* csResp = strdup("");
- char ch;
- long rc = 0;
-
- bool bCheckMultiLine = true;
-
- while(bCheckMultiLine)
- {
- while( strlen(csResp) < 2 || strcmp(csResp + strlen(csResp) - 2, "\r\n") != 0)
- {
- if (recv(sock, &ch, 1, 0 ) < 0)
- {
- LogFile.eSysLog("EPGSearch: error receiving response!");
- free(csResp);
- return -1;
- }
- char* Temp = NULL;
- msprintf(&Temp, "%s%c", csResp, ch);
- free(csResp);
- csResp = Temp;
- }
- if( csResp[3] == ' ' )
- {
- bCheckMultiLine = false;
- rc = atol(csResp);
- }
- free(csResp);
- csResp = strdup("");
- }
- free(csResp);
- return rc;
- }
+ cSVDRPClient() {
+ bConnected = false;
+ sock = socket(PF_INET, SOCK_STREAM, 0);
+ if (sock < 0) {
+ LogFile.eSysLog("error creating socket!");
+ return;
+ }
+
+ struct sockaddr_in AdrSock;
+ AdrSock.sin_family = AF_INET;
+ AdrSock.sin_port = htons(EPGSearchConfig.SVDRPPort);
+ inet_aton("127.0.0.1", &AdrSock.sin_addr);
+
+ if (connect(sock, (struct sockaddr*)&AdrSock, sizeof(AdrSock)) == -1) {
+ LogFile.eSysLog("error connecting to socket!");
+ return;
+ }
+ bConnected = (Receive() == SVDRPCONNECT);
+ if (!bConnected)
+ LogFile.eSysLog("EPGSearch: could not connect to VDR!");
+ }
+
+ ~cSVDRPClient() {
+ if (sock >= 0)
+ close(sock);
+ }
+
+ bool SendCmd(const char* cmd) {
+ if (!bConnected)
+ return false;
+
+ cString szCmd = cString::sprintf("%s\r\n", cmd);
+ Send(*szCmd);
+ bool cmdret = (Receive() == CMDSUCCESS);
+
+ szCmd = cString::sprintf("QUIT\r\n");
+ Send(szCmd);
+
+ long rc = 0;
+ if ((rc = Receive()) != SVDRPDISCONNECT)
+ LogFile.eSysLog("could not disconnect (%ld)!", rc);
+
+ close(sock);
+ sock = -1;
+ return cmdret;
+ }
+ bool Send(const char* szSend) {
+ int length = strlen(szSend);
+ int sent = 0;
+ do {
+ sent += send(sock, szSend + sent, length - sent, 0);
+ if (sent < 0) {
+ LogFile.eSysLog("error sending command!");
+ return false;
+ }
+ } while (sent < length);
+ return true;
+ }
+ long Receive() {
+ char* csResp = strdup("");
+ char ch;
+ long rc = 0;
+
+ bool bCheckMultiLine = true;
+
+ while (bCheckMultiLine) {
+ while (strlen(csResp) < 2 || strcmp(csResp + strlen(csResp) - 2, "\r\n") != 0) {
+ if (recv(sock, &ch, 1, 0) < 0) {
+ LogFile.eSysLog("EPGSearch: error receiving response!");
+ free(csResp);
+ return -1;
+ }
+ char* Temp = NULL;
+ msprintf(&Temp, "%s%c", csResp, ch);
+ free(csResp);
+ csResp = Temp;
+ }
+ if (csResp[3] == ' ') {
+ bCheckMultiLine = false;
+ rc = atol(csResp);
+ }
+ free(csResp);
+ csResp = strdup("");
+ }
+ free(csResp);
+ return rc;
+ }
static const char *SVDRPSendCmd;
};
diff --git a/switchtimer.c b/switchtimer.c
index b01172e..e69ed68 100644
--- a/switchtimer.c
+++ b/switchtimer.c
@@ -38,11 +38,10 @@ cSwitchTimer::cSwitchTimer(const cEvent* Event, int SwitchMinsBefore, int Mode,
{
eventID = 0;
startTime = 0;
- if (Event)
- {
- eventID = Event->EventID();
- channelID = Event->ChannelID();
- startTime = Event->StartTime();
+ if (Event) {
+ eventID = Event->EventID();
+ channelID = Event->ChannelID();
+ startTime = Event->StartTime();
}
switchMinsBefore = SwitchMinsBefore;
mode = Mode;
@@ -62,97 +61,94 @@ cSwitchTimer& cSwitchTimer::operator= (const cSwitchTimer &SwitchTimer)
bool cSwitchTimer::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];
- startTime=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 > MAXVALUELEN)
- valuelen = MAXVALUELEN;
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- switch (parameter) {
- case 1:
- channelID = tChannelID::FromString(value);
- break;
- case 2:
- eventID = atoi(value);
- break;
- case 3:
- startTime = atol(value);
- break;
- case 4:
- switchMinsBefore = atoi(value);
- break;
- case 5:
- mode = atoi(value);
- break;
- case 6:
- unmute = atoi(value);
- break;
- default:
- break;
- } //switch
- }
- parameter++;
- }
- if (*pos) pos++;
- } //while
+ char value[MAXVALUELEN];
+ startTime = 0;
- free(line);
- return (parameter >= 3) ? true : false;
+ 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)
+ valuelen = MAXVALUELEN;
+ strn0cpy(value, pos, valuelen);
+ pos = pos_next;
+ switch (parameter) {
+ case 1:
+ channelID = tChannelID::FromString(value);
+ break;
+ case 2:
+ eventID = atoi(value);
+ break;
+ case 3:
+ startTime = atol(value);
+ break;
+ case 4:
+ switchMinsBefore = atoi(value);
+ break;
+ case 5:
+ mode = atoi(value);
+ break;
+ case 6:
+ unmute = atoi(value);
+ break;
+ default:
+ break;
+ } //switch
+ }
+ parameter++;
+ }
+ if (*pos) pos++;
+ } //while
+
+ free(line);
+ return (parameter >= 3) ? true : false;
}
const cEvent* cSwitchTimer::Event()
{
- time_t now = time(NULL);
- const cEvent* event = NULL;
- if (startTime > now)
- {
- LOCK_SCHEDULES_READ;
- if (!Schedules) return NULL;
- const cSchedule *Schedule = Schedules->GetSchedule(channelID);
- if (Schedule)
- {
- event = Schedule->GetEvent(eventID, startTime);
- if (!event)
- event = Schedule->GetEventAround(startTime);
- }
- }
- return event;
+ time_t now = time(NULL);
+ const cEvent* event = NULL;
+ if (startTime > now) {
+ LOCK_SCHEDULES_READ;
+ if (!Schedules) return NULL;
+ const cSchedule *Schedule = Schedules->GetSchedule(channelID);
+ if (Schedule) {
+ event = Schedule->GetEvent(eventID, startTime);
+ if (!event)
+ event = Schedule->GetEventAround(startTime);
+ }
+ }
+ return event;
}
cString cSwitchTimer::ToText(bool& ignore)
{
ignore = false;
- if (!Event())
- {
- ignore = true;
- return NULL;
+ if (!Event()) {
+ ignore = true;
+ return NULL;
}
LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByChannelID(channelID, true, true);
if (!channel) return NULL;
cString buffer = cString::sprintf("%s:%u:%ld:%d:%d:%d",
- CHANNELSTRING(channel), eventID,
- startTime, switchMinsBefore,
- mode, unmute?1:0);
+ CHANNELSTRING(channel), eventID,
+ startTime, switchMinsBefore,
+ mode, unmute ? 1 : 0);
return buffer;
}
@@ -161,7 +157,7 @@ bool cSwitchTimer::Save(FILE *f)
bool ignore = false;
cString buffer = ToText(ignore);
if (!ignore)
- return fprintf(f, "%s\n", *buffer) > 0;
+ return fprintf(f, "%s\n", *buffer) > 0;
return true;
}
@@ -171,13 +167,12 @@ cSwitchTimer* cSwitchTimers::InSwitchList(const cEvent* event)
if (!event) return NULL;
cMutexLock SwitchTimersLock(this);
cSwitchTimer* switchTimer = SwitchTimers.First();
- while (switchTimer)
- {
- if (switchTimer->eventID == event->EventID() &&
- switchTimer->channelID == event->ChannelID() &&
- switchTimer->startTime == event->StartTime())
- return switchTimer;
- switchTimer = SwitchTimers.Next(switchTimer);
+ while (switchTimer) {
+ if (switchTimer->eventID == event->EventID() &&
+ switchTimer->channelID == event->ChannelID() &&
+ switchTimer->startTime == event->StartTime())
+ return switchTimer;
+ switchTimer = SwitchTimers.Next(switchTimer);
}
return NULL;
}
@@ -186,11 +181,10 @@ bool cSwitchTimers::Exists(const cSwitchTimer* SwitchTimer)
{
cMutexLock SwitchTimersLock(this);
cSwitchTimer* switchTimer = SwitchTimers.First();
- while (switchTimer)
- {
- if (switchTimer == SwitchTimer)
- return true;
- switchTimer = SwitchTimers.Next(switchTimer);
+ while (switchTimer) {
+ if (switchTimer == SwitchTimer)
+ return true;
+ switchTimer = SwitchTimers.Next(switchTimer);
}
return false;
}
diff --git a/switchtimer.h b/switchtimer.h
index 695249b..88c860a 100644
--- a/switchtimer.h
+++ b/switchtimer.h
@@ -38,7 +38,7 @@ public:
int unmute;
cSwitchTimer(void);
- cSwitchTimer(const cEvent* Event, int SwitchMinsBefore=1, int mode=0, int unmute=0);
+ cSwitchTimer(const cEvent* Event, int SwitchMinsBefore = 1, int mode = 0, int unmute = 0);
cSwitchTimer& operator= (const cSwitchTimer &SwitchTimer);
const cEvent* Event();
bool Parse(const char *s);
diff --git a/switchtimer_thread.c b/switchtimer_thread.c
index be1c12a..5aea47b 100644
--- a/switchtimer_thread.c
+++ b/switchtimer_thread.c
@@ -33,125 +33,121 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
cSwitchTimerThread *cSwitchTimerThread::m_Instance = NULL;
cSwitchTimerThread::cSwitchTimerThread(void)
- : cThread("EPGSearch: switchtimer")
+ : cThread("EPGSearch: switchtimer")
{
- m_Active = false;
- m_lastUpdate = time(NULL);
+ m_Active = false;
+ m_lastUpdate = time(NULL);
}
-cSwitchTimerThread::~cSwitchTimerThread() {
- if (m_Active)
- Stop();
+cSwitchTimerThread::~cSwitchTimerThread()
+{
+ if (m_Active)
+ Stop();
}
-void cSwitchTimerThread::Init(void) {
- if (m_Instance == NULL && SwitchTimers.Count() > 0) {
- m_Instance = new cSwitchTimerThread;
- m_Instance->Start();
- }
+void cSwitchTimerThread::Init(void)
+{
+ if (m_Instance == NULL && SwitchTimers.Count() > 0) {
+ m_Instance = new cSwitchTimerThread;
+ m_Instance->Start();
+ }
}
-void cSwitchTimerThread::Exit(void) {
- if (m_Instance != NULL) {
- m_Instance->Stop();
- DELETENULL(m_Instance);
- }
+void cSwitchTimerThread::Exit(void)
+{
+ if (m_Instance != NULL) {
+ m_Instance->Stop();
+ DELETENULL(m_Instance);
+ }
}
-void cSwitchTimerThread::Stop(void) {
- m_Active = false;
- Wait.Signal();
- Cancel(6);
+void cSwitchTimerThread::Stop(void)
+{
+ m_Active = false;
+ Wait.Signal();
+ Cancel(6);
}
void cSwitchTimerThread::Action(void)
{
- m_Active = true;
-
- // let VDR do its startup
- if (!cPluginEpgsearch::VDR_readyafterStartup)
- LogFile.Log(2, "SwitchTimerThread: waiting for VDR to become ready...");
- while(m_Active && !cPluginEpgsearch::VDR_readyafterStartup)
- Wait.Wait(1000);
-
- time_t nextUpdate = time(NULL);
- while (m_Active)
- {
- time_t now = time(NULL);
- if (now >= nextUpdate)
- {
- LogFile.Log(3,"locking switch timers");
- SwitchTimers.cMutex::Lock();
- LogFile.Log(3,"switch timer check started");
- cSwitchTimer* switchTimer = SwitchTimers.First();
- while (switchTimer && m_Active && Running())
- {
- if (switchTimer->startTime - now < switchTimer->switchMinsBefore*60 + MSG_DELAY + 1)
- {
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(switchTimer->channelID, true, true);
- bool doSwitch = (switchTimer->mode == 0);
- bool doAsk = (switchTimer->mode == 2);
- bool doUnmute = switchTimer->unmute;
- SwitchTimers.Del(switchTimer);
-
- const cEvent* event = switchTimer->Event();
- if (event && channel && (event->EndTime() >= now))
- {
- cString Message = cString::sprintf("%s: %s - %s", event->Title(),
- CHANNELNAME(channel), GETTIMESTRING(event));
- cString SwitchCmd = cString::sprintf("CHAN %d", channel->Number());
- // switch
- if (doSwitch)
- {
- LogFile.Log(1,"switching to channel %d", channel->Number());
- if (cDevice::CurrentChannel() != channel->Number())
- SendViaSVDRP(SwitchCmd);
-
- if (doUnmute && cDevice::PrimaryDevice()->IsMute())
- cDevice::PrimaryDevice()->ToggleMute();
- }
- if (!doAsk)
- SendMsg(Message);
-
- if (doAsk)
- {
- cString Message = cString::sprintf(tr("Switch to (%d) '%s'?"), channel->Number(), event->Title());
- if(SendMsg(Message, true, MSG_DELAY) == kOk)
- {
- LogFile.Log(1,"switching to channel %d", channel->Number());
- if (cDevice::CurrentChannel() != channel->Number())
- SendViaSVDRP(SwitchCmd);
-
- if (doUnmute && cDevice::PrimaryDevice()->IsMute())
- cDevice::PrimaryDevice()->ToggleMute();
-
- }
- }
-
- if (m_Active && Running())
- Wait.Wait(1000 * MSG_DELAY);
- }
- SwitchTimers.Save();
- break;
+ m_Active = true;
+
+ // let VDR do its startup
+ if (!cPluginEpgsearch::VDR_readyafterStartup)
+ LogFile.Log(2, "SwitchTimerThread: waiting for VDR to become ready...");
+ while (m_Active && !cPluginEpgsearch::VDR_readyafterStartup)
+ Wait.Wait(1000);
+
+ time_t nextUpdate = time(NULL);
+ while (m_Active) {
+ time_t now = time(NULL);
+ if (now >= nextUpdate) {
+ LogFile.Log(3, "locking switch timers");
+ SwitchTimers.cMutex::Lock();
+ LogFile.Log(3, "switch timer check started");
+ cSwitchTimer* switchTimer = SwitchTimers.First();
+ while (switchTimer && m_Active && Running()) {
+ if (switchTimer->startTime - now < switchTimer->switchMinsBefore * 60 + MSG_DELAY + 1) {
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(switchTimer->channelID, true, true);
+ bool doSwitch = (switchTimer->mode == 0);
+ bool doAsk = (switchTimer->mode == 2);
+ bool doUnmute = switchTimer->unmute;
+ SwitchTimers.Del(switchTimer);
+
+ const cEvent* event = switchTimer->Event();
+ if (event && channel && (event->EndTime() >= now)) {
+ cString Message = cString::sprintf("%s: %s - %s", event->Title(),
+ CHANNELNAME(channel), GETTIMESTRING(event));
+ cString SwitchCmd = cString::sprintf("CHAN %d", channel->Number());
+ // switch
+ if (doSwitch) {
+ LogFile.Log(1, "switching to channel %d", channel->Number());
+ if (cDevice::CurrentChannel() != channel->Number())
+ SendViaSVDRP(SwitchCmd);
+
+ if (doUnmute && cDevice::PrimaryDevice()->IsMute())
+ cDevice::PrimaryDevice()->ToggleMute();
+ }
+ if (!doAsk)
+ SendMsg(Message);
+
+ if (doAsk) {
+ cString Message = cString::sprintf(tr("Switch to (%d) '%s'?"), channel->Number(), event->Title());
+ if (SendMsg(Message, true, MSG_DELAY) == kOk) {
+ LogFile.Log(1, "switching to channel %d", channel->Number());
+ if (cDevice::CurrentChannel() != channel->Number())
+ SendViaSVDRP(SwitchCmd);
+
+ if (doUnmute && cDevice::PrimaryDevice()->IsMute())
+ cDevice::PrimaryDevice()->ToggleMute();
+
+ }
+ }
+
+ if (m_Active && Running())
+ Wait.Wait(1000 * MSG_DELAY);
+ }
+ SwitchTimers.Save();
+ break;
+ }
+ switchTimer = SwitchTimers.Next(switchTimer);
}
- switchTimer = SwitchTimers.Next(switchTimer);
- }
- SwitchTimers.Unlock();
- LogFile.Log(3,"switch timer check finished");
- if (m_Active && Running())
- Wait.Wait(1000 * MSG_DELAY);
- m_lastUpdate = time(NULL);
- nextUpdate = long(m_lastUpdate/60)*60+ 60 - MSG_DELAY ; // check at each full minute minus 5sec
- if (SwitchTimers.Count() == 0)
- m_Active = false;
- if (!Running())
- m_Active = false;
- }
- while (m_Active && time(NULL)%MSG_DELAY != 0) // sync heart beat to MSG_DELAY
- Wait.Wait(1000);
- Wait.Wait(1000);
- };
- m_Instance = NULL;
+ SwitchTimers.Unlock();
+ LogFile.Log(3, "switch timer check finished");
+ if (m_Active && Running())
+ Wait.Wait(1000 * MSG_DELAY);
+ m_lastUpdate = time(NULL);
+ nextUpdate = long(m_lastUpdate / 60) * 60 + 60 - MSG_DELAY ; // check at each full minute minus 5sec
+ if (SwitchTimers.Count() == 0)
+ m_Active = false;
+ if (!Running())
+ m_Active = false;
+ }
+ while (m_Active && time(NULL) % MSG_DELAY != 0) // sync heart beat to MSG_DELAY
+ Wait.Wait(1000);
+ Wait.Wait(1000);
+ };
+ m_Instance = NULL;
}
diff --git a/switchtimer_thread.h b/switchtimer_thread.h
index 31bc311..6c02914 100644
--- a/switchtimer_thread.h
+++ b/switchtimer_thread.h
@@ -27,15 +27,16 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "switchtimer.h"
#include <vdr/thread.h>
-class cSwitchTimerThread: public cThread {
- private:
+class cSwitchTimerThread: public cThread
+{
+private:
bool m_Active;
time_t m_lastUpdate;
cCondWait Wait;
- protected:
+protected:
virtual void Action(void);
void Stop(void);
- public:
+public:
static cSwitchTimerThread *m_Instance;
cSwitchTimerThread(void);
diff --git a/templatefile.c b/templatefile.c
index a2536f5..e2a6498 100644
--- a/templatefile.c
+++ b/templatefile.c
@@ -34,91 +34,82 @@ bool cMenuTemplate::PrepareTemplate(const char* templateLine)
if (!templateLine || strlen(templateLine) == 0) return true;
char *pstrSearchToken, *pptr;
- char *pstrSearch=strdup(templateLine);
- pstrSearchToken=strtok_r(pstrSearch, "|", &pptr);
+ char *pstrSearch = strdup(templateLine);
+ pstrSearchToken = strtok_r(pstrSearch, "|", &pptr);
cString stripped;
int iToken = 0;
- while(pstrSearchToken)
- {
- char* tmp = strchr(pstrSearchToken,':');
- if (tmp)
- {
- int tabWidth = atoi(tmp+1);
- if (tabWidth == 0)
- {
- LogFile.eSysLog("warning - tab width in \"%s\" is 0, set to min value 1!", Name());
- tabWidth = 1;
- }
- menuTabs[iToken++] = tabWidth;
- }
- else
- {
- free(pstrSearch);
- LogFile.eSysLog("error parsing entry \"%s\", falling back to default entries.", Name());
- return false;
- }
- *tmp = 0;
- if (isempty(stripped))
- stripped = strdup(pstrSearchToken);
- else
- {
- cString tmp = stripped;
- stripped = cString::sprintf("%s|%s", *tmp, pstrSearchToken);
- }
- pstrSearchToken=strtok_r(NULL, "|", &pptr);
+ while (pstrSearchToken) {
+ char* tmp = strchr(pstrSearchToken, ':');
+ if (tmp) {
+ int tabWidth = atoi(tmp + 1);
+ if (tabWidth == 0) {
+ LogFile.eSysLog("warning - tab width in \"%s\" is 0, set to min value 1!", Name());
+ tabWidth = 1;
+ }
+ menuTabs[iToken++] = tabWidth;
+ } else {
+ free(pstrSearch);
+ LogFile.eSysLog("error parsing entry \"%s\", falling back to default entries.", Name());
+ return false;
+ }
+ *tmp = 0;
+ if (isempty(stripped))
+ stripped = strdup(pstrSearchToken);
+ else {
+ cString tmp = stripped;
+ stripped = cString::sprintf("%s|%s", *tmp, pstrSearchToken);
+ }
+ pstrSearchToken = strtok_r(NULL, "|", &pptr);
}
free(pstrSearch);
// no limit for the last column
- if (iToken>0) menuTabs[iToken-1] = 0;
-
- if (!isempty(stripped))
- {
- menuTemplate = strdup(stripped);
- // the status variables are handled in menu_whatson.c itself
- // to speedup the var-parser we 'hide' them here in renaming them
- menuTemplate = strreplacei(menuTemplate, "%status%", "$status$");
- menuTemplate = strreplacei(menuTemplate, "%t_status%", "$t_status$");
- menuTemplate = strreplacei(menuTemplate, "%v_status%", "$v_status$");
- menuTemplate = strreplacei(menuTemplate, "%r_status%", "$r_status$");
- }
+ if (iToken > 0) menuTabs[iToken - 1] = 0;
+
+ if (!isempty(stripped)) {
+ menuTemplate = strdup(stripped);
+ // the status variables are handled in menu_whatson.c itself
+ // to speedup the var-parser we 'hide' them here in renaming them
+ menuTemplate = strreplacei(menuTemplate, "%status%", "$status$");
+ menuTemplate = strreplacei(menuTemplate, "%t_status%", "$t_status$");
+ menuTemplate = strreplacei(menuTemplate, "%v_status%", "$v_status$");
+ menuTemplate = strreplacei(menuTemplate, "%r_status%", "$r_status$");
+ }
return true;
}
cTemplLine::cTemplLine(void)
{
- name = value = NULL;
+ name = value = NULL;
}
cTemplLine::cTemplLine(const char *Name, const char *Value)
{
- name = strdup(Name);
- value = strdup(Value);
+ name = strdup(Name);
+ value = strdup(Value);
}
cTemplLine::~cTemplLine()
{
- free(name);
- free(value);
+ free(name);
+ free(value);
}
bool cTemplLine::Parse(char *s)
{
if (!s) return false;
if (s[0] == '#')
- return true;
+ return true;
char *p = strchr(s, '=');
- if (p)
- {
- *p = 0;
- char *Name = compactspace(s);
- char *Value = compactspace(p + 1);
- if (*Name)
- {
- name = strdup(Name);
- value = strdup(Value);
- return true;
- }
+ if (p) {
+ *p = 0;
+ char *Name = compactspace(s);
+ char *Value = compactspace(p + 1);
+ if (*Name) {
+ name = strdup(Name);
+ value = strdup(Value);
+ return true;
+ }
}
return false;
}
@@ -132,7 +123,7 @@ void cTemplFile::Reset()
{
std::set<cMenuTemplate*>::iterator it;
for (it = menuTemplates.begin(); it != menuTemplates.end(); ++it)
- delete (*it);
+ delete(*it);
menuTemplates.clear();
}
@@ -140,69 +131,60 @@ cMenuTemplate* cTemplFile::GetTemplateByName(const char* Name)
{
std::set<cMenuTemplate*>::iterator it;
for (it = menuTemplates.begin(); it != menuTemplates.end(); ++it)
- if (!strcasecmp(Name, (*it)->Name())) return (*it);
+ if (!strcasecmp(Name, (*it)->Name())) return (*it);
return NULL;
}
bool cTemplFile::Load(const char *FileName)
{
- // auto-enable WarEagle-Icons if VDRSymbols font is used
- if (strstr(Setup.FontOsd, "VDRSymbols") == Setup.FontOsd)
- EPGSearchConfig.WarEagle = 1;
-
- if (cConfig<cTemplLine>::Load(FileName, true))
- {
- bool result = true;
- for (cTemplLine *l = First(); l; l = Next(l))
- {
- bool error = false;
- if (!Parse(l->Name(), l->Value()))
- error = true;
- if (error)
- {
- result = false;
- }
- }
- return result;
- }
- return false;
+ // auto-enable WarEagle-Icons if VDRSymbols font is used
+ if (strstr(Setup.FontOsd, "VDRSymbols") == Setup.FontOsd)
+ EPGSearchConfig.WarEagle = 1;
+
+ if (cConfig<cTemplLine>::Load(FileName, true)) {
+ bool result = true;
+ for (cTemplLine *l = First(); l; l = Next(l)) {
+ bool error = false;
+ if (!Parse(l->Name(), l->Value()))
+ error = true;
+ if (error) {
+ result = false;
+ }
+ }
+ return result;
+ }
+ return false;
}
bool cTemplFile::Parse(const char *Name, const char *Value)
{
if (Name && Name[0] == '#') return true;
- if (!strcasecmp(Name, "WarEagleIcons"))
- {
- EPGSearchConfig.WarEagle = atoi(Value);
- return true;
+ if (!strcasecmp(Name, "WarEagleIcons")) {
+ EPGSearchConfig.WarEagle = atoi(Value);
+ return true;
}
if (!strcasecmp(Name, "MenuWhatsOnNow") ||
- !strcasecmp(Name, "MenuWhatsOnNext") ||
- !strcasecmp(Name, "MenuWhatsOnElse") ||
- !strcasecmp(Name, "MenuSchedule") ||
- !strncasecmp(Name, "MenuSearchResults", strlen("MenuSearchResults")) ||
- !strcasecmp(Name, "MenuFavorites"))
- {
- cMenuTemplate* menuTemplate = new cMenuTemplate(Name);
- if (menuTemplate->PrepareTemplate(Value))
- {
- LogFile.Log(3, "loaded menu template: %s", Name);
- cMenuTemplate* TemplOld = GetTemplateByName(Name);
- if (TemplOld)
- {
- LogFile.Log(1, "menu template '%s' gets overwritten", Name);
- menuTemplates.erase(TemplOld);
- delete TemplOld;
- }
- menuTemplates.insert(menuTemplate);
- return true;
- }
- }
- else
- {
- LogFile.eSysLog("ERROR: unknown parameter: %s = %s", Name, Value);
- return false;
+ !strcasecmp(Name, "MenuWhatsOnNext") ||
+ !strcasecmp(Name, "MenuWhatsOnElse") ||
+ !strcasecmp(Name, "MenuSchedule") ||
+ !strncasecmp(Name, "MenuSearchResults", strlen("MenuSearchResults")) ||
+ !strcasecmp(Name, "MenuFavorites")) {
+ cMenuTemplate* menuTemplate = new cMenuTemplate(Name);
+ if (menuTemplate->PrepareTemplate(Value)) {
+ LogFile.Log(3, "loaded menu template: %s", Name);
+ cMenuTemplate* TemplOld = GetTemplateByName(Name);
+ if (TemplOld) {
+ LogFile.Log(1, "menu template '%s' gets overwritten", Name);
+ menuTemplates.erase(TemplOld);
+ delete TemplOld;
+ }
+ menuTemplates.insert(menuTemplate);
+ return true;
+ }
+ } else {
+ LogFile.eSysLog("ERROR: unknown parameter: %s = %s", Name, Value);
+ return false;
}
return true;
}
@@ -210,106 +192,95 @@ bool cTemplFile::Parse(const char *Name, const char *Value)
void cTemplFile::PrepareDefaultTemplates()
{
char channelnr[20] = "";
- {
- LOCK_CHANNELS_READ; // Channels used in CHNUMWIDTH
- sprintf(channelnr, "%%chnr%%:%d|", CHNUMWIDTH);
- }
+ {
+ LOCK_CHANNELS_READ; // Channels used in CHNUMWIDTH
+ sprintf(channelnr, "%%chnr%%:%d|", CHNUMWIDTH);
+ }
bool text2skin = !(strcmp(Setup.OSDSkin, "soppalusikka") == 0 ||
- strcmp(Setup.OSDSkin, "classic") == 0 ||
- strcmp(Setup.OSDSkin, "sttng") == 0);
+ strcmp(Setup.OSDSkin, "classic") == 0 ||
+ strcmp(Setup.OSDSkin, "sttng") == 0);
char menutemplate[MAXTEMPLLEN] = "";
// What's on now
cMenuTemplate* WhatsOnNow = GetTemplateByName("MenuWhatsOnNow");
- if (!WhatsOnNow)
- {
- WhatsOnNow = new cMenuTemplate("MenuWhatsOnNow");
- menuTemplates.insert(WhatsOnNow);
+ if (!WhatsOnNow) {
+ WhatsOnNow = new cMenuTemplate("MenuWhatsOnNow");
+ menuTemplates.insert(WhatsOnNow);
}
- if (WhatsOnNow && WhatsOnNow->MenuTemplate() == 0)
- {
- sprintf(menutemplate, "%s%%chsh%%:12|%%time%%:6|%s%s$status$:3|%%title%% ~ %%subtitle%%:30",
- EPGSearchConfig.showChannelNr?channelnr:"",
- EPGSearchConfig.showProgress==0?"":(EPGSearchConfig.showProgress==1?"%progrT2S%:4|":"%progr%:5|"),
- text2skin?" ":"");
- WhatsOnNow->PrepareTemplate(menutemplate);
+ if (WhatsOnNow && WhatsOnNow->MenuTemplate() == 0) {
+ sprintf(menutemplate, "%s%%chsh%%:12|%%time%%:6|%s%s$status$:3|%%title%% ~ %%subtitle%%:30",
+ EPGSearchConfig.showChannelNr ? channelnr : "",
+ EPGSearchConfig.showProgress == 0 ? "" : (EPGSearchConfig.showProgress == 1 ? "%progrT2S%:4|" : "%progr%:5|"),
+ text2skin ? " " : "");
+ WhatsOnNow->PrepareTemplate(menutemplate);
}
// What's on next and else
sprintf(menutemplate, "%s%%chsh%%:12|%%time%%:7|$status$:4|%%title%% ~ %%subtitle%%:30",
- EPGSearchConfig.showChannelNr?channelnr:"");
+ EPGSearchConfig.showChannelNr ? channelnr : "");
cMenuTemplate* WhatsOnNext = GetTemplateByName("MenuWhatsOnNext");
- if (!WhatsOnNext)
- {
- WhatsOnNext = new cMenuTemplate("MenuWhatsOnNext");
- menuTemplates.insert(WhatsOnNext);
+ if (!WhatsOnNext) {
+ WhatsOnNext = new cMenuTemplate("MenuWhatsOnNext");
+ menuTemplates.insert(WhatsOnNext);
}
if (WhatsOnNext && WhatsOnNext->MenuTemplate() == 0)
- WhatsOnNext->PrepareTemplate(menutemplate);
+ WhatsOnNext->PrepareTemplate(menutemplate);
cMenuTemplate* WhatsOnElse = GetTemplateByName("MenuWhatsOnElse");
- if (!WhatsOnElse)
- {
- WhatsOnElse = new cMenuTemplate("MenuWhatsOnElse");
- menuTemplates.insert(WhatsOnElse);
+ if (!WhatsOnElse) {
+ WhatsOnElse = new cMenuTemplate("MenuWhatsOnElse");
+ menuTemplates.insert(WhatsOnElse);
}
if (WhatsOnElse && WhatsOnElse->MenuTemplate() == 0)
- WhatsOnElse->PrepareTemplate(menutemplate);
+ WhatsOnElse->PrepareTemplate(menutemplate);
// Schedule
cMenuTemplate* Schedule = GetTemplateByName("MenuSchedule");
- if (!Schedule)
- {
- Schedule = new cMenuTemplate("MenuSchedule");
- menuTemplates.insert(Schedule);
+ if (!Schedule) {
+ Schedule = new cMenuTemplate("MenuSchedule");
+ menuTemplates.insert(Schedule);
}
- if (Schedule && Schedule->MenuTemplate() == 0)
- {
- strcpy(menutemplate, "%time_w% %time_d%:7|%time%:6|$status$:4|%title% ~ %subtitle%:30");
- Schedule->PrepareTemplate(menutemplate);
+ if (Schedule && Schedule->MenuTemplate() == 0) {
+ strcpy(menutemplate, "%time_w% %time_d%:7|%time%:6|$status$:4|%title% ~ %subtitle%:30");
+ Schedule->PrepareTemplate(menutemplate);
}
// Search results
cMenuTemplate* SearchResults = GetTemplateByName("MenuSearchResults");
- if (!SearchResults)
- {
- SearchResults = new cMenuTemplate("MenuSearchResults");
- menuTemplates.insert(SearchResults);
+ if (!SearchResults) {
+ SearchResults = new cMenuTemplate("MenuSearchResults");
+ menuTemplates.insert(SearchResults);
}
- if (SearchResults && SearchResults->MenuTemplate() == 0)
- {
- sprintf(menutemplate, "%s%%chsh%%:12|%%datesh%%:6|%%time%%:6|$status$:3|%%title%% ~ %%subtitle%%:30",
- EPGSearchConfig.showChannelNr?channelnr:"");
- SearchResults->PrepareTemplate(menutemplate);
+ if (SearchResults && SearchResults->MenuTemplate() == 0) {
+ sprintf(menutemplate, "%s%%chsh%%:12|%%datesh%%:6|%%time%%:6|$status$:3|%%title%% ~ %%subtitle%%:30",
+ EPGSearchConfig.showChannelNr ? channelnr : "");
+ SearchResults->PrepareTemplate(menutemplate);
}
// Favorites
cMenuTemplate* Favorites = GetTemplateByName("MenuFavorites");
- if (!Favorites)
- {
- Favorites = new cMenuTemplate("MenuFavorites");
- menuTemplates.insert(Favorites);
+ if (!Favorites) {
+ Favorites = new cMenuTemplate("MenuFavorites");
+ menuTemplates.insert(Favorites);
}
- if (Favorites && Favorites->MenuTemplate() == 0)
- {
- sprintf(menutemplate, "%s%%chsh%%:12|%%time%%:6|%%timespan%%:7|$status$:3|%%title%% ~ %%subtitle%%:30",
- EPGSearchConfig.showChannelNr?channelnr:"");
- Favorites->PrepareTemplate(menutemplate);
+ if (Favorites && Favorites->MenuTemplate() == 0) {
+ sprintf(menutemplate, "%s%%chsh%%:12|%%time%%:6|%%timespan%%:7|$status$:3|%%title%% ~ %%subtitle%%:30",
+ EPGSearchConfig.showChannelNr ? channelnr : "");
+ Favorites->PrepareTemplate(menutemplate);
}
// create an array of all search template names
if (SearchTemplates)
- delete [] SearchTemplates;
+ delete [] SearchTemplates;
SearchTemplates = new char*[CountSearchResultsTemplates()];
std::set<cMenuTemplate*>::iterator it;
int Count = 0;
for (it = menuTemplates.begin(); it != menuTemplates.end(); ++it)
- if (!strncasecmp("MenuSearchResults", (*it)->Name(), strlen("MenuSearchResults")))
- {
- char* templateName = strdup((*it)->Name() + strlen("MenuSearchResults"));
- if (*templateName == 0) templateName = strdup(tr("Standard"));
- SearchTemplates[Count++] = templateName;
- }
+ if (!strncasecmp("MenuSearchResults", (*it)->Name(), strlen("MenuSearchResults"))) {
+ char* templateName = strdup((*it)->Name() + strlen("MenuSearchResults"));
+ if (*templateName == 0) templateName = strdup(tr("Standard"));
+ SearchTemplates[Count++] = templateName;
+ }
}
int cTemplFile::CountSearchResultsTemplates()
@@ -317,7 +288,7 @@ int cTemplFile::CountSearchResultsTemplates()
int Count = 0;
std::set<cMenuTemplate*>::iterator it;
for (it = menuTemplates.begin(); it != menuTemplates.end(); ++it)
- if (!strncasecmp("MenuSearchResults", (*it)->Name(), strlen("MenuSearchResults"))) Count++;
+ if (!strncasecmp("MenuSearchResults", (*it)->Name(), strlen("MenuSearchResults"))) Count++;
return Count;
}
@@ -326,8 +297,8 @@ cMenuTemplate* cTemplFile::GetSearchTemplateByPos(int iPos)
int Count = 0;
std::set<cMenuTemplate*>::iterator it;
for (it = menuTemplates.begin(); it != menuTemplates.end(); ++it)
- if (!strncasecmp("MenuSearchResults", (*it)->Name(), strlen("MenuSearchResults")))
- if(Count++ == iPos)
- return (*it);
+ if (!strncasecmp("MenuSearchResults", (*it)->Name(), strlen("MenuSearchResults")))
+ if (Count++ == iPos)
+ return (*it);
return NULL;
}
diff --git a/templatefile.h b/templatefile.h
index 3439269..0aa448f 100644
--- a/templatefile.h
+++ b/templatefile.h
@@ -34,38 +34,47 @@ using std::set;
class cMenuTemplate
{
- private:
+private:
char name[MAXTEMPLLEN];
char* menuTemplate;
int menuTabs[cSkinDisplayMenu::MaxTabs];
- public:
- cMenuTemplate(const char* Name)
- {
- strcpy(name, Name);
- menuTemplate = 0;
- for(int i=0; i<cSkinDisplayMenu::MaxTabs; i++) menuTabs[i] = 0;
- }
- ~cMenuTemplate()
- {
- if (menuTemplate) free(menuTemplate);
- }
- const char* Name(void) {return name;}
- const char* MenuTemplate(void) {return menuTemplate;}
- int Tab(int i) {return menuTabs[i];}
+public:
+ cMenuTemplate(const char* Name) {
+ strcpy(name, Name);
+ menuTemplate = 0;
+ for (int i = 0; i < cSkinDisplayMenu::MaxTabs; i++) menuTabs[i] = 0;
+ }
+ ~cMenuTemplate() {
+ if (menuTemplate) free(menuTemplate);
+ }
+ const char* Name(void) {
+ return name;
+ }
+ const char* MenuTemplate(void) {
+ return menuTemplate;
+ }
+ int Tab(int i) {
+ return menuTabs[i];
+ }
bool PrepareTemplate(const char* templateLine);
};
-class cTemplLine : public cListObject {
+class cTemplLine : public cListObject
+{
private:
- char *name;
- char *value;
+ char *name;
+ char *value;
public:
- cTemplLine(void);
- cTemplLine(const char *Name, const char *Value);
- virtual ~cTemplLine();
- const char *Name(void) { return name; }
- const char *Value(void) { return value; }
- bool Parse(char *s);
+ cTemplLine(void);
+ cTemplLine(const char *Name, const char *Value);
+ virtual ~cTemplLine();
+ const char *Name(void) {
+ return name;
+ }
+ const char *Value(void) {
+ return value;
+ }
+ bool Parse(char *s);
};
diff --git a/timer_thread.c b/timer_thread.c
index ba82c41..f01cdb6 100644
--- a/timer_thread.c
+++ b/timer_thread.c
@@ -38,37 +38,41 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
cTimerThread *cTimerThread::m_Instance = NULL;
TimerThreadStatus cTimerThread::m_Status = TimerThreadReady;
-int gl_TimerProgged=0; // Flag that indicates, when programming is finished
+int gl_TimerProgged = 0; // Flag that indicates, when programming is finished
cTimerThread::cTimerThread()
-: cThread("EPGSearch: timer")
+ : cThread("EPGSearch: timer")
{
m_Active = false;
}
-cTimerThread::~cTimerThread() {
+cTimerThread::~cTimerThread()
+{
if (m_Active)
- Stop();
+ Stop();
cTimerThread::m_Instance = NULL;
}
-void cTimerThread::Init(cString cmd) {
+void cTimerThread::Init(cString cmd)
+{
if (m_Instance == NULL) {
- m_Instance = new cTimerThread;
- m_Instance->m_cmd = cmd;
- m_Instance->Start();
+ m_Instance = new cTimerThread;
+ m_Instance->m_cmd = cmd;
+ m_Instance->Start();
}
}
-void cTimerThread::Exit(void) {
+void cTimerThread::Exit(void)
+{
if (m_Instance != NULL) {
- m_Instance->Stop();
- DELETENULL(m_Instance);
+ m_Instance->Stop();
+ DELETENULL(m_Instance);
}
}
-void cTimerThread::Stop(void) {
+void cTimerThread::Stop(void)
+{
m_Active = false;
Cancel(3);
}
@@ -76,38 +80,32 @@ void cTimerThread::Stop(void) {
void cTimerThread::Action(void)
{
m_Active = true;
- if (EPGSearchConfig.useExternalSVDRP && !epgsSVDRP::cSVDRPClient::SVDRPSendCmd)
- {
- LogFile.eSysLog("ERROR - SVDRPSend script not specified or does not exist (use -f option)");
- m_Active = false;
- return;
+ if (EPGSearchConfig.useExternalSVDRP && !epgsSVDRP::cSVDRPClient::SVDRPSendCmd) {
+ LogFile.eSysLog("ERROR - SVDRPSend script not specified or does not exist (use -f option)");
+ m_Active = false;
+ return;
}
- while (m_Active)
- {
- if (!Running())
- {
- m_Active=false;
+ while (m_Active) {
+ if (!Running()) {
+ m_Active = false;
break;
}
- {
- LOCK_TIMERS_WRITE;
- Timers->SetExplicitModify();
- }
- bool bSuccess = SendViaSVDRP(m_cmd);
- if (!bSuccess)
- {
- Epgsearch_osdmessage_v1_0* service_data = new Epgsearch_osdmessage_v1_0;
- service_data->message = strdup(tr("Programming timer failed!"));
- service_data->type = mtError;
- cPluginManager::CallFirstService("Epgsearch-osdmessage-v1.0", service_data);
- delete service_data;
- }
- else
- {
- gl_TimerProgged = 1;
- if (gl_timerStatusMonitor) gl_timerStatusMonitor->SetConflictCheckAdvised();
- }
- m_Active = false;
+ {
+ LOCK_TIMERS_WRITE;
+ Timers->SetExplicitModify();
+ }
+ bool bSuccess = SendViaSVDRP(m_cmd);
+ if (!bSuccess) {
+ Epgsearch_osdmessage_v1_0* service_data = new Epgsearch_osdmessage_v1_0;
+ service_data->message = strdup(tr("Programming timer failed!"));
+ service_data->type = mtError;
+ cPluginManager::CallFirstService("Epgsearch-osdmessage-v1.0", service_data);
+ delete service_data;
+ } else {
+ gl_TimerProgged = 1;
+ if (gl_timerStatusMonitor) gl_timerStatusMonitor->SetConflictCheckAdvised();
+ }
+ m_Active = false;
};
}
diff --git a/timer_thread.h b/timer_thread.h
index af5ee69..1922511 100644
--- a/timer_thread.h
+++ b/timer_thread.h
@@ -30,30 +30,35 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
extern int gl_TimerProgged;
-typedef enum
-{
+typedef enum {
TimerThreadReady,
TimerThreadWorking,
TimerThreadError,
TimerThreadDone
} TimerThreadStatus;
-class cTimerThread: public cThread {
+class cTimerThread: public cThread
+{
private:
- static cTimerThread *m_Instance;
- cString m_cmd;
- static TimerThreadStatus m_Status;
+ static cTimerThread *m_Instance;
+ cString m_cmd;
+ static TimerThreadStatus m_Status;
protected:
- virtual void Action(void);
- void Stop(void);
+ virtual void Action(void);
+ void Stop(void);
public:
- bool m_Active;
- TimerThreadStatus GetStatus() { return cTimerThread::m_Status; }
- void SetStatus(TimerThreadStatus Status) { LogFile.eSysLog("%d", int(Status)); cTimerThread::m_Status = Status; }
- cTimerThread();
- virtual ~cTimerThread();
- void Init(cString);
- void Exit(void);
+ bool m_Active;
+ TimerThreadStatus GetStatus() {
+ return cTimerThread::m_Status;
+ }
+ void SetStatus(TimerThreadStatus Status) {
+ LogFile.eSysLog("%d", int(Status));
+ cTimerThread::m_Status = Status;
+ }
+ cTimerThread();
+ virtual ~cTimerThread();
+ void Init(cString);
+ void Exit(void);
};
#endif
diff --git a/timerdone.c b/timerdone.c
index 0940225..7ad2151 100644
--- a/timerdone.c
+++ b/timerdone.c
@@ -31,183 +31,180 @@ cTimersDone TimersDone;
// -- cTimerDone -----------------------------------------------------------------
cTimerDone::cTimerDone(void)
{
- start = stop = 0;
- searchID = -1;
+ start = stop = 0;
+ searchID = -1;
}
cTimerDone::cTimerDone(const time_t Start, const time_t Stop, const cEvent* pEvent, const int SearchID)
{
- start = Start;
- stop = Stop;
- if (pEvent)
- {
- channelID = pEvent->ChannelID();
- title = pEvent->Title()?pEvent->Title():"";
- shorttext = pEvent->ShortText()?pEvent->ShortText():"";
- }
- searchID = SearchID;
+ start = Start;
+ stop = Stop;
+ if (pEvent) {
+ channelID = pEvent->ChannelID();
+ title = pEvent->Title() ? pEvent->Title() : "";
+ shorttext = pEvent->ShortText() ? pEvent->ShortText() : "";
+ }
+ searchID = SearchID;
}
bool cTimerDone::operator== (const cTimerDone &arg) const
{
- if (start == arg.start && stop == arg.stop && channelID == arg.channelID)
- {
- if (title != arg.title) return false;
- if (shorttext != "" && arg.shorttext != "" && shorttext != arg.shorttext) return false;
-
- if (searchID > -1 && arg.searchID > -1)
- return searchID == arg.searchID;
- else
- return true;
- }
- else
- return false;
+ if (start == arg.start && stop == arg.stop && channelID == arg.channelID) {
+ if (title != arg.title) return false;
+ if (shorttext != "" && arg.shorttext != "" && shorttext != arg.shorttext) return false;
+
+ if (searchID > -1 && arg.searchID > -1)
+ return searchID == arg.searchID;
+ else
+ return true;
+ } else
+ return false;
}
bool cTimerDone::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;
+ 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:
+ channelID = tChannelID::FromString(value);
+ break;
+ case 2:
+ start = atol(value);
+ break;
+ case 3:
+ stop = atol(value);
+ break;
+ case 4:
+ searchID = atol(value);
+ break;
+ case 5:
+ title = value;
+ break;
+ case 6:
+ shorttext = value;
+ break;
+ default:
+ break;
+ } //switch
}
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- switch (parameter) {
- case 1: channelID = tChannelID::FromString(value);
- break;
- case 2: start = atol(value);
- break;
- case 3: stop = atol(value);
- break;
- case 4: searchID = atol(value);
- break;
- case 5: title = value;
- break;
- case 6: shorttext = value;
- break;
- default:
- break;
- } //switch
- }
- parameter++;
- }
- if (*pos) pos++;
- } //while
-
-
- title = ReplaceAll(title, "|", ":");
- shorttext = ReplaceAll(shorttext, "|", ":");
-
- free(line);
- return (parameter >= 6) ? true : false;
+ parameter++;
+ }
+ if (*pos) pos++;
+ } //while
+
+
+ title = ReplaceAll(title, "|", ":");
+ shorttext = ReplaceAll(shorttext, "|", ":");
+
+ free(line);
+ return (parameter >= 6) ? true : false;
}
cString cTimerDone::ToText(void) const
{
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(channelID, true, true);
- string info = string(DAYDATETIME(start)) + " - " + string(channel?channel->Name():"");
-
- cString buffer = cString::sprintf("%s:%ld:%ld:%d:%s:%s:%s",
- *channelID.ToString(),
- start,
- stop,
- searchID,
- ReplaceAll(title, ":", "|").c_str(),
- ReplaceAll(shorttext, ":", "|").c_str(),
- ReplaceAll(info, ":", "|").c_str());
- return buffer;
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(channelID, true, true);
+ string info = string(DAYDATETIME(start)) + " - " + string(channel ? channel->Name() : "");
+
+ cString buffer = cString::sprintf("%s:%ld:%ld:%d:%s:%s:%s",
+ *channelID.ToString(),
+ start,
+ stop,
+ searchID,
+ ReplaceAll(title, ":", "|").c_str(),
+ ReplaceAll(shorttext, ":", "|").c_str(),
+ ReplaceAll(info, ":", "|").c_str());
+ return buffer;
}
bool cTimerDone::Save(FILE *f)
{
- return fprintf(f, "%s\n", *ToText()) > 0;
+ return fprintf(f, "%s\n", *ToText()) > 0;
}
const cEvent* cTimerDone::GetEvent() const
{
LOCK_SCHEDULES_READ;
- if (!Schedules) return NULL;
- const cSchedule *Schedule = Schedules->GetSchedule(channelID);
- if (!Schedule) return NULL;
- const cEvent* Event = Schedule->GetEventAround(start + (stop - start)/2);
- return Event;
+ if (!Schedules) return NULL;
+ const cSchedule *Schedule = Schedules->GetSchedule(channelID);
+ if (!Schedule) return NULL;
+ const cEvent* Event = Schedule->GetEventAround(start + (stop - start) / 2);
+ return Event;
}
// -- cTimerDones -----------------------------------------------------------------
cTimerDone* cTimersDone::InList(const time_t Start, const time_t Stop, const cEvent* pEvent, const int SearchID)
{
- cTimerDone td(Start, Stop, pEvent, SearchID);
- cTimerDone* timerdone = First();
- while (timerdone)
- {
- if (*timerdone == td)
- return timerdone;
- timerdone = Next(timerdone);
- }
- return NULL;
+ cTimerDone td(Start, Stop, pEvent, SearchID);
+ cTimerDone* timerdone = First();
+ while (timerdone) {
+ if (*timerdone == td)
+ return timerdone;
+ timerdone = Next(timerdone);
+ }
+ return NULL;
}
void cTimersDone::ClearOutdated(void)
{
- // remove outdated items
- cTimerDone* timerdone = First();
- while (timerdone)
- {
- cTimerDone* timerdoneNext = Next(timerdone);
- if (timerdone->stop < time(NULL))
- Del(timerdone);
- timerdone = timerdoneNext;
- }
+ // remove outdated items
+ cTimerDone* timerdone = First();
+ while (timerdone) {
+ cTimerDone* timerdoneNext = Next(timerdone);
+ if (timerdone->stop < time(NULL))
+ Del(timerdone);
+ timerdone = timerdoneNext;
+ }
}
void cTimersDone::Update(const time_t Start, const time_t Stop, const cEvent* pEvent, const int SearchID, cTimerDone* Timerdone)
{
- cTimerDone* timerdone = InList(Start, Stop, pEvent, SearchID);
- if(timerdone)
- {
- timerdone->start = Timerdone->start;
- timerdone->stop = Timerdone->stop;
- timerdone->channelID = Timerdone->channelID;
- timerdone->searchID = Timerdone->searchID;
- timerdone->title = Timerdone->title;
- timerdone->shorttext = Timerdone->shorttext;
- delete Timerdone;
- }
- else
- Add(Timerdone);
+ cTimerDone* timerdone = InList(Start, Stop, pEvent, SearchID);
+ if (timerdone) {
+ timerdone->start = Timerdone->start;
+ timerdone->stop = Timerdone->stop;
+ timerdone->channelID = Timerdone->channelID;
+ timerdone->searchID = Timerdone->searchID;
+ timerdone->title = Timerdone->title;
+ timerdone->shorttext = Timerdone->shorttext;
+ delete Timerdone;
+ } else
+ Add(Timerdone);
}
void cTimersDone::RemoveEntriesOfSearch(const int SearchID)
{
- cTimerDone* timerdone = First();
- while (timerdone)
- {
- cTimerDone* timerdoneNext = Next(timerdone);
- if (timerdone->searchID == SearchID)
- Del(timerdone);
- timerdone = timerdoneNext;
- }
+ cTimerDone* timerdone = First();
+ while (timerdone) {
+ cTimerDone* timerdoneNext = Next(timerdone);
+ if (timerdone->searchID == SearchID)
+ Del(timerdone);
+ timerdone = timerdoneNext;
+ }
}
diff --git a/timerdone.h b/timerdone.h
index e3c4719..3305049 100644
--- a/timerdone.h
+++ b/timerdone.h
@@ -30,7 +30,8 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
using std::string;
// --- cTimerDone --------------------------------------------------------
-class cTimerDone : public cListObject {
+class cTimerDone : public cListObject
+{
public:
time_t start; // Start time of the timer
time_t stop; // Stop time of the timer
@@ -50,8 +51,9 @@ public:
const cEvent* GetEvent() const;
};
-class cTimersDone : public cConfig<cTimerDone>, public cMutex {
- public:
+class cTimersDone : public cConfig<cTimerDone>, public cMutex
+{
+public:
cTimerDone* InList(const time_t Start, const time_t Stop, const cEvent* pEvent, const int SearchID);
void Update(const time_t Start, const time_t Stop, const cEvent* pEvent, const int SearchID, cTimerDone* timerdone);
void ClearOutdated(void);
diff --git a/timerstatus.c b/timerstatus.c
index 9c5e1fb..219702f 100644
--- a/timerstatus.c
+++ b/timerstatus.c
@@ -27,25 +27,25 @@ cTimerStatusMonitor* gl_timerStatusMonitor = NULL;
cTimerStatusMonitor::cTimerStatusMonitor()
{
- conflictCheckAdvised = true;
+ conflictCheckAdvised = true;
}
void cTimerStatusMonitor::TimerChange(const cTimer *Timer, eTimerChange Change)
{
- // vdr-1.5.15 and above will inform us, when there are any timer changes.
- // so timer changes (within epgsearch) in previous versions have to be tracked
- // at the correspondig places.
- conflictCheckAdvised = true;
+ // vdr-1.5.15 and above will inform us, when there are any timer changes.
+ // so timer changes (within epgsearch) in previous versions have to be tracked
+ // at the correspondig places.
+ conflictCheckAdvised = true;
}
void cTimerStatusMonitor::SetConflictCheckAdvised(bool ConflictCheckAdvised)
{
- if (!ConflictCheckAdvised)
- conflictCheckAdvised = false;
+ if (!ConflictCheckAdvised)
+ conflictCheckAdvised = false;
}
bool cTimerStatusMonitor::ConflictCheckAdvised()
{
- return conflictCheckAdvised;
+ return conflictCheckAdvised;
}
diff --git a/timerstatus.h b/timerstatus.h
index 5e25a4a..29b20cd 100644
--- a/timerstatus.h
+++ b/timerstatus.h
@@ -25,13 +25,13 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
class cTimerStatusMonitor : public cStatus
{
- bool conflictCheckAdvised;
- protected:
- virtual void TimerChange(const cTimer *Timer, eTimerChange Change);
- public:
- cTimerStatusMonitor();
- void SetConflictCheckAdvised(bool ConflictCheckAdvised = true);
- bool ConflictCheckAdvised();
+ bool conflictCheckAdvised;
+protected:
+ virtual void TimerChange(const cTimer *Timer, eTimerChange Change);
+public:
+ cTimerStatusMonitor();
+ void SetConflictCheckAdvised(bool ConflictCheckAdvised = true);
+ bool ConflictCheckAdvised();
};
extern cTimerStatusMonitor* gl_timerStatusMonitor;
diff --git a/uservars.c b/uservars.c
index 389ce6f..ae2626b 100644
--- a/uservars.c
+++ b/uservars.c
@@ -43,385 +43,363 @@ string cSearchVar::nameSpace = "search";
cUserVar::cUserVar()
{
- oldEvent = NULL;
- oldescapeStrings = false;
+ oldEvent = NULL;
+ oldescapeStrings = false;
}
string cUserVar::Evaluate(const cEvent* e, bool escapeStrings)
{
- if (oldEvent && oldEvent == e && oldescapeStrings == escapeStrings)
- return oldResult;
- usedVars.clear();
- string result;
- if (IsShellCmd())
- result = EvaluateShellCmd(e);
- else if (IsConnectCmd())
- result = EvaluateConnectCmd(e);
- else if (IsLengthCmd())
- result = EvaluateLengthCmd(e);
- else if (IsCondExpr())
- result = EvaluateCondExpr(e);
- else
- result = EvaluateCompExpr(e);
- oldResult = result;
- oldEvent = e;
- oldescapeStrings = escapeStrings;
-
- // avoid double dir separators
- int pos = 0;
- while((pos = result.find("~~")) >= 0)
- result.replace(pos, 2, "~");
-
- return result;
+ if (oldEvent && oldEvent == e && oldescapeStrings == escapeStrings)
+ return oldResult;
+ usedVars.clear();
+ string result;
+ if (IsShellCmd())
+ result = EvaluateShellCmd(e);
+ else if (IsConnectCmd())
+ result = EvaluateConnectCmd(e);
+ else if (IsLengthCmd())
+ result = EvaluateLengthCmd(e);
+ else if (IsCondExpr())
+ result = EvaluateCondExpr(e);
+ else
+ result = EvaluateCompExpr(e);
+ oldResult = result;
+ oldEvent = e;
+ oldescapeStrings = escapeStrings;
+
+ // avoid double dir separators
+ int pos = 0;
+ while ((pos = result.find("~~")) >= 0)
+ result.replace(pos, 2, "~");
+
+ return result;
}
string cUserVar::EvaluateShellCmd(const cEvent* e)
{
- if (!varparser.cmd) return "";
- string cmdArgs;
- if (varparser.cmdArgs != "")
- {
- string args = varparser.cmdArgs;
- varparser.compExpr = args; //handle the args as composed expr
- cmdArgs = EvaluateCompExpr(e, true);
- }
- const char* res = varparser.cmd->Execute(cmdArgs.c_str());
- string result = res?res:"";
- int crPos = 0; // remove any CR
- while((crPos = result.find("\n")) >= 0)
- result.replace(crPos, 1, "");
-
- return result;
+ if (!varparser.cmd) return "";
+ string cmdArgs;
+ if (varparser.cmdArgs != "") {
+ string args = varparser.cmdArgs;
+ varparser.compExpr = args; //handle the args as composed expr
+ cmdArgs = EvaluateCompExpr(e, true);
+ }
+ const char* res = varparser.cmd->Execute(cmdArgs.c_str());
+ string result = res ? res : "";
+ int crPos = 0; // remove any CR
+ while ((crPos = result.find("\n")) >= 0)
+ result.replace(crPos, 1, "");
+
+ return result;
}
#define MAX_LINE 1000
string cUserVar::EvaluateConnectCmd(const cEvent* e)
{
- if (varparser.connectAddr == "") return "";
-
- int conn_s; /* connection socket */
- struct sockaddr_in servaddr; /* socket address structure */
- char buffer[MAX_LINE]; /* character buffer */
-
- if ( (conn_s = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
- {
- LogFile.eSysLog("Error creating listening socket");
- return "";
- }
-
- memset(&servaddr, 0, sizeof(varparser.connectAddr.c_str()));
- servaddr.sin_family = AF_INET;
- servaddr.sin_port = htons(varparser.connectPort);
-
- if (getAddrFromString(varparser.connectAddr.c_str(), &servaddr) != 0)
- {
- LogFile.eSysLog("Invalid remote address");
- return "";
- }
-
- if ( connect(conn_s, (struct sockaddr *) &servaddr, sizeof(servaddr) ) < 0 )
- {
- LogFile.eSysLog("Error calling connect()");
- return "";
- }
-
- varparser.compExpr = varparser.cmdArgs;
- string resexp = EvaluateCompExpr(e, true);
- sprintf(buffer, "%s\n", resexp.c_str());
- Writeline(conn_s, buffer, strlen(buffer));
- Readline(conn_s, buffer, MAX_LINE-1);
-
- close(conn_s);
- return buffer;
+ if (varparser.connectAddr == "") return "";
+
+ int conn_s; /* connection socket */
+ struct sockaddr_in servaddr; /* socket address structure */
+ char buffer[MAX_LINE]; /* character buffer */
+
+ if ((conn_s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ LogFile.eSysLog("Error creating listening socket");
+ return "";
+ }
+
+ memset(&servaddr, 0, sizeof(varparser.connectAddr.c_str()));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_port = htons(varparser.connectPort);
+
+ if (getAddrFromString(varparser.connectAddr.c_str(), &servaddr) != 0) {
+ LogFile.eSysLog("Invalid remote address");
+ return "";
+ }
+
+ if (connect(conn_s, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0) {
+ LogFile.eSysLog("Error calling connect()");
+ return "";
+ }
+
+ varparser.compExpr = varparser.cmdArgs;
+ string resexp = EvaluateCompExpr(e, true);
+ sprintf(buffer, "%s\n", resexp.c_str());
+ Writeline(conn_s, buffer, strlen(buffer));
+ Readline(conn_s, buffer, MAX_LINE - 1);
+
+ close(conn_s);
+ return buffer;
}
string cUserVar::EvaluateLengthCmd(const cEvent* e)
{
- return NumToString(EvaluateCompExpr(e, false).size());
+ return NumToString(EvaluateCompExpr(e, false).size());
}
string cUserVar::EvaluateCondExpr(const cEvent* e, bool escapeStrings)
{
- string condresult = "";
- cVarExpr leftExp(varparser.condEqLeft);
- string resLeft = leftExp.Evaluate(e);
- cVarExpr rightExp(varparser.condEqRight);
- string resRight = rightExp.Evaluate(e);
- if (varparser.condOp == condEq && resLeft == resRight) condresult = "1"; // assign any value
- if (varparser.condOp == condNeq && resLeft != resRight) condresult = "1"; // assign any value
-
- cUserVar* condVarTrue = UserVars.GetFromName(varparser.condvarTrue);
- cUserVar* condVarFalse = UserVars.GetFromName(varparser.condvarFalse);
- if (!condVarTrue || !condVarFalse) return "";
-
- if (!AddDepVar(condVarTrue)) return "";
- if (!AddDepVar(condVarFalse)) return "";
-
- if (condresult != "")
- {
- LogFile.Log(3, "using case 'true'");
- return condVarTrue->Evaluate(e, escapeStrings);
- }
- else
- {
- LogFile.Log(3, "using case 'false'");
- return condVarFalse->Evaluate(e, escapeStrings);
- }
+ string condresult = "";
+ cVarExpr leftExp(varparser.condEqLeft);
+ string resLeft = leftExp.Evaluate(e);
+ cVarExpr rightExp(varparser.condEqRight);
+ string resRight = rightExp.Evaluate(e);
+ if (varparser.condOp == condEq && resLeft == resRight) condresult = "1"; // assign any value
+ if (varparser.condOp == condNeq && resLeft != resRight) condresult = "1"; // assign any value
+
+ cUserVar* condVarTrue = UserVars.GetFromName(varparser.condvarTrue);
+ cUserVar* condVarFalse = UserVars.GetFromName(varparser.condvarFalse);
+ if (!condVarTrue || !condVarFalse) return "";
+
+ if (!AddDepVar(condVarTrue)) return "";
+ if (!AddDepVar(condVarFalse)) return "";
+
+ if (condresult != "") {
+ LogFile.Log(3, "using case 'true'");
+ return condVarTrue->Evaluate(e, escapeStrings);
+ } else {
+ LogFile.Log(3, "using case 'false'");
+ return condVarFalse->Evaluate(e, escapeStrings);
+ }
}
string cUserVar::EvaluateCompExpr(const cEvent* e, bool escapeStrings)
{
- string expr = varparser.compExpr;
- if (expr.find('%') == string::npos) return expr;
+ string expr = varparser.compExpr;
+ if (expr.find('%') == string::npos) return expr;
- // handle internal vars like title and subtitle
- expr = EvaluateInternalVars(expr, e, escapeStrings);
+ // handle internal vars like title and subtitle
+ expr = EvaluateInternalVars(expr, e, escapeStrings);
- // replace ext. EPG variables
- expr = EvaluateExtEPGVars(expr, e, escapeStrings);
+ // replace ext. EPG variables
+ expr = EvaluateExtEPGVars(expr, e, escapeStrings);
- // replace other user vars
- expr = EvaluateUserVars(expr, e, escapeStrings);
+ // replace other user vars
+ expr = EvaluateUserVars(expr, e, escapeStrings);
- return expr;
+ return expr;
}
string cUserVar::EvaluateInternalVars(const string& Expr, const cEvent* e, bool escapeStrings)
{
- string expr = Expr;
- if (expr.find('%') == string::npos) return expr;
-
- std::map<string, cInternalVar*>::iterator it;
- for (it = UserVars.internalVars.begin(); it != UserVars.internalVars.end(); ++it)
- {
- string varName = (it->second)->Name();
- int varPos = 0;
- while((varPos = FindIgnoreCase(expr, varName)) >= 0)
- {
- usedVars.insert(it->second);
- expr.replace(varPos, varName.size(), (it->second)->Evaluate(e, escapeStrings));
- }
- }
- return expr;
+ string expr = Expr;
+ if (expr.find('%') == string::npos) return expr;
+
+ std::map<string, cInternalVar*>::iterator it;
+ for (it = UserVars.internalVars.begin(); it != UserVars.internalVars.end(); ++it) {
+ string varName = (it->second)->Name();
+ int varPos = 0;
+ while ((varPos = FindIgnoreCase(expr, varName)) >= 0) {
+ usedVars.insert(it->second);
+ expr.replace(varPos, varName.size(), (it->second)->Evaluate(e, escapeStrings));
+ }
+ }
+ return expr;
}
string cUserVar::EvaluateExtEPGVars(const string& Expr, const cEvent* e, bool escapeStrings)
{
- string expr = Expr;
- if (expr.find('%') == string::npos) return expr;
-
- std::map<string, cExtEPGVar*>::iterator evar;
- for (evar = UserVars.extEPGVars.begin(); evar != UserVars.extEPGVars.end(); ++evar)
- {
- // replace ext. EPG variables with leading namespace
- string varName = evar->second->Name(true);
- int varPos = 0;
- while((varPos = FindIgnoreCase(expr, varName)) >= 0)
- {
- expr.replace(varPos, varName.size(), evar->second->Evaluate(e, escapeStrings));
- usedVars.insert(evar->second);
- }
- // replace ext. EPG variables without leading namespace
- varName = evar->second->Name();
- varPos = 0;
- while((varPos = FindIgnoreCase(expr, varName)) >= 0)
- {
- expr.replace(varPos, varName.size(), evar->second->Evaluate(e, escapeStrings));
- usedVars.insert(evar->second);
- }
- }
- return expr;
+ string expr = Expr;
+ if (expr.find('%') == string::npos) return expr;
+
+ std::map<string, cExtEPGVar*>::iterator evar;
+ for (evar = UserVars.extEPGVars.begin(); evar != UserVars.extEPGVars.end(); ++evar) {
+ // replace ext. EPG variables with leading namespace
+ string varName = evar->second->Name(true);
+ int varPos = 0;
+ while ((varPos = FindIgnoreCase(expr, varName)) >= 0) {
+ expr.replace(varPos, varName.size(), evar->second->Evaluate(e, escapeStrings));
+ usedVars.insert(evar->second);
+ }
+ // replace ext. EPG variables without leading namespace
+ varName = evar->second->Name();
+ varPos = 0;
+ while ((varPos = FindIgnoreCase(expr, varName)) >= 0) {
+ expr.replace(varPos, varName.size(), evar->second->Evaluate(e, escapeStrings));
+ usedVars.insert(evar->second);
+ }
+ }
+ return expr;
}
string cUserVar::EvaluateUserVars(const string& Expr, const cEvent* e, bool escapeStrings)
{
- string expr = Expr;
- if (expr.find('%') == string::npos) return expr;
-
- std::set<cUserVar*>::iterator it;
- for (it = UserVars.userVars.begin(); it != UserVars.userVars.end(); ++it)
- {
- string varName = (*it)->Name();
- int varPos = 0;
- while((varPos = FindIgnoreCase(expr, varName)) >= 0)
- {
- if (!AddDepVar(*it)) return "";
- expr.replace(varPos, varName.size(), (*it)->Evaluate(e, escapeStrings));
- }
- }
- return expr;
+ string expr = Expr;
+ if (expr.find('%') == string::npos) return expr;
+
+ std::set<cUserVar*>::iterator it;
+ for (it = UserVars.userVars.begin(); it != UserVars.userVars.end(); ++it) {
+ string varName = (*it)->Name();
+ int varPos = 0;
+ while ((varPos = FindIgnoreCase(expr, varName)) >= 0) {
+ if (!AddDepVar(*it)) return "";
+ expr.replace(varPos, varName.size(), (*it)->Evaluate(e, escapeStrings));
+ }
+ }
+ return expr;
}
string cUserVar::EvaluateInternalTimerVars(const string& Expr, const cTimer* t)
{
- string expr = Expr;
- if (expr.find('%') == string::npos) return expr;
-
- std::map<string, cTimerVar*>::iterator tvar;
- for (tvar = UserVars.internalTimerVars.begin(); tvar != UserVars.internalTimerVars.end(); ++tvar)
- {
- string varName = tvar->second->Name();
- int varPos = 0;
-
- while((varPos = FindIgnoreCase(expr, varName)) >= 0)
- {
- expr.replace(varPos, varName.size(), tvar->second->Evaluate(t));
- }
- }
- return expr;
+ string expr = Expr;
+ if (expr.find('%') == string::npos) return expr;
+
+ std::map<string, cTimerVar*>::iterator tvar;
+ for (tvar = UserVars.internalTimerVars.begin(); tvar != UserVars.internalTimerVars.end(); ++tvar) {
+ string varName = tvar->second->Name();
+ int varPos = 0;
+
+ while ((varPos = FindIgnoreCase(expr, varName)) >= 0) {
+ expr.replace(varPos, varName.size(), tvar->second->Evaluate(t));
+ }
+ }
+ return expr;
}
string cUserVar::EvaluateInternalSearchVars(const string& Expr, const cSearchExt* s)
{
- string expr = Expr;
- if (expr.find('%') == string::npos) return expr;
-
- std::map<string, cSearchVar*>::iterator svar;
- for (svar = UserVars.internalSearchVars.begin(); svar != UserVars.internalSearchVars.end(); ++svar)
- {
- string varName = svar->second->Name();
- int varPos = 0;
- while((varPos = FindIgnoreCase(expr, varName)) >= 0)
- {
- expr.replace(varPos, varName.size(), svar->second->Evaluate(s));
- }
- }
- return expr;
+ string expr = Expr;
+ if (expr.find('%') == string::npos) return expr;
+
+ std::map<string, cSearchVar*>::iterator svar;
+ for (svar = UserVars.internalSearchVars.begin(); svar != UserVars.internalSearchVars.end(); ++svar) {
+ string varName = svar->second->Name();
+ int varPos = 0;
+ while ((varPos = FindIgnoreCase(expr, varName)) >= 0) {
+ expr.replace(varPos, varName.size(), svar->second->Evaluate(s));
+ }
+ }
+ return expr;
}
bool cUserVar::DependsOnVar(const string& varName)
{
- string VarName = Strip(varName);
- cUserVar* var = UserVars.GetFromName(VarName);
- if (!var) return false;
- return DependsOnVar(var);
+ string VarName = Strip(varName);
+ cUserVar* var = UserVars.GetFromName(VarName);
+ if (!var) return false;
+ return DependsOnVar(var);
}
bool cUserVar::DependsOnVar(cUserVar* var)
{
- if (!var) return false;
- if (usedVars.find(var) != usedVars.end()) return true;
- std::set<cUserVar*>::iterator it;
- for (it = usedVars.begin(); it != usedVars.end(); ++it)
- if ((*it)->DependsOnVar(var))
- return true;
- return false;
+ if (!var) return false;
+ if (usedVars.find(var) != usedVars.end()) return true;
+ std::set<cUserVar*>::iterator it;
+ for (it = usedVars.begin(); it != usedVars.end(); ++it)
+ if ((*it)->DependsOnVar(var))
+ return true;
+ return false;
}
bool cUserVar::AddDepVar(cUserVar* var)
{
- if (var == this || var->DependsOnVar(this))
- {
- LogFile.eSysLog("ERROR - found cylic reference to var '%s' in var '%s'", var->Name().c_str(), Name().c_str());
- return false;
- }
- usedVars.insert(var);
- return true;
+ if (var == this || var->DependsOnVar(this)) {
+ LogFile.eSysLog("ERROR - found cylic reference to var '%s' in var '%s'", var->Name().c_str(), Name().c_str());
+ return false;
+ }
+ usedVars.insert(var);
+ return true;
}
void cUserVar::ResetCache()
{
- oldEvent = NULL;
- oldResult = "";
+ oldEvent = NULL;
+ oldResult = "";
}
// cUserVarLine
bool cUserVarLine::Parse(char *s)
{
- if (!s) return false;
- if (s[0] == '#')
- return true;
- char *p = strchr(s, '=');
- if (p)
- {
- cUserVar* userVar = new cUserVar;
- if (userVar->varparser.Parse(s))
- {
- cUserVar* oldVar = UserVars.GetFromName(userVar->Name(), false);
- if (oldVar) // allow redefintion of existing vars
- {
- LogFile.Log(1, "variable '%s' gets overwritten", oldVar->Name().c_str());
- UserVars.userVars.erase(oldVar);
- delete oldVar;
- }
- UserVars.userVars.insert(userVar);
- return true;
- }
- }
- return false;
+ if (!s) return false;
+ if (s[0] == '#')
+ return true;
+ char *p = strchr(s, '=');
+ if (p) {
+ cUserVar* userVar = new cUserVar;
+ if (userVar->varparser.Parse(s)) {
+ cUserVar* oldVar = UserVars.GetFromName(userVar->Name(), false);
+ if (oldVar) { // allow redefintion of existing vars
+ LogFile.Log(1, "variable '%s' gets overwritten", oldVar->Name().c_str());
+ UserVars.userVars.erase(oldVar);
+ delete oldVar;
+ }
+ UserVars.userVars.insert(userVar);
+ return true;
+ }
+ }
+ return false;
}
// cUserVars
cUserVar* cUserVars::GetFromName(const string& varName, bool log)
{
- string VarName = Strip(varName);
- std::transform(VarName.begin(), VarName.end(), VarName.begin(), tolower);
+ string VarName = Strip(varName);
+ std::transform(VarName.begin(), VarName.end(), VarName.begin(), tolower);
- std::map<string, cInternalVar*>::iterator ivar = internalVars.find(VarName);
- if (ivar != internalVars.end())
- return ivar->second;
+ std::map<string, cInternalVar*>::iterator ivar = internalVars.find(VarName);
+ if (ivar != internalVars.end())
+ return ivar->second;
- std::set<cUserVar*>::iterator uvar;
- for (uvar = userVars.begin(); uvar != userVars.end(); ++uvar)
- if (EqualsNoCase((*uvar)->Name(), VarName))
- return (*uvar);
+ std::set<cUserVar*>::iterator uvar;
+ for (uvar = userVars.begin(); uvar != userVars.end(); ++uvar)
+ if (EqualsNoCase((*uvar)->Name(), VarName))
+ return (*uvar);
- std::map<string, cExtEPGVar*>::iterator evar = extEPGVars.find(VarName);
- if (evar != extEPGVars.end())
- return evar->second;
+ std::map<string, cExtEPGVar*>::iterator evar = extEPGVars.find(VarName);
+ if (evar != extEPGVars.end())
+ return evar->second;
- if (log)
- LogFile.eSysLog("var '%s' not defined!", VarName.c_str());
- return NULL;
+ if (log)
+ LogFile.eSysLog("var '%s' not defined!", VarName.c_str());
+ return NULL;
}
// cVarExpr
string cVarExpr::Evaluate(const cEvent* e)
{
- // create a dummy user var
- cUserVar var;
- if (!var.varparser.ParseExp(expr))
- return "";
-
- LogFile.Log(3, "start evaluating expression '%s'", expr.c_str());
- string result = var.Evaluate(e);
- LogFile.Log(3, "stop evaluating expression '%s' - result: '%s'", expr.c_str(), result.c_str());
- usedVars = var.usedVars;
- return result;
+ // create a dummy user var
+ cUserVar var;
+ if (!var.varparser.ParseExp(expr))
+ return "";
+
+ LogFile.Log(3, "start evaluating expression '%s'", expr.c_str());
+ string result = var.Evaluate(e);
+ LogFile.Log(3, "stop evaluating expression '%s' - result: '%s'", expr.c_str(), result.c_str());
+ usedVars = var.usedVars;
+ return result;
}
string cVarExpr::Evaluate(const cTimer* t)
{
- // create a dummy user var
- cUserVar var;
- if (!var.varparser.ParseExp(expr))
- return "";
+ // create a dummy user var
+ cUserVar var;
+ if (!var.varparser.ParseExp(expr))
+ return "";
- usedVars = var.usedVars;
- return var.EvaluateInternalTimerVars(expr, t);
+ usedVars = var.usedVars;
+ return var.EvaluateInternalTimerVars(expr, t);
}
string cVarExpr::Evaluate(const cSearchExt* s)
{
- // create a dummy user var
- cUserVar var;
- if (!var.varparser.ParseExp(expr))
- return "";
+ // create a dummy user var
+ cUserVar var;
+ if (!var.varparser.ParseExp(expr))
+ return "";
- usedVars = var.usedVars;
- return var.EvaluateInternalSearchVars(expr, s);
+ usedVars = var.usedVars;
+ return var.EvaluateInternalSearchVars(expr, s);
}
bool cVarExpr::DependsOnVar(const string& varName, const cEvent* e)
{
- string VarName = Strip(varName);
- if (FindIgnoreCase(expr, VarName) >= 0)
- return true;
- // create a dummy user var
- cUserVar var;
- var.varparser.varName = expr;
- if (!var.varparser.ParseExp(expr))
- return false;
- var.Evaluate(e);
- return var.DependsOnVar(VarName);
+ string VarName = Strip(varName);
+ if (FindIgnoreCase(expr, VarName) >= 0)
+ return true;
+ // create a dummy user var
+ cUserVar var;
+ var.varparser.varName = expr;
+ if (!var.varparser.ParseExp(expr))
+ return false;
+ var.Evaluate(e);
+ return var.DependsOnVar(VarName);
}
diff --git a/uservars.h b/uservars.h
index 546a816..2e8a2f7 100644
--- a/uservars.h
+++ b/uservars.h
@@ -40,7 +40,8 @@ using std::set;
using std::map;
using std::ostringstream;
-class cUserVar : public cListObject {
+class cUserVar : public cListObject
+{
const cEvent* oldEvent; // cache
bool oldescapeStrings;
@@ -62,667 +63,713 @@ public:
string EvaluateInternalSearchVars(const string& Expr, const cSearchExt* s);
string EvaluateExtEPGVars(const string& Expr, const cEvent* e, bool escapeStrings = false);
string EvaluateUserVars(const string& Expr, const cEvent* e, bool escapeStrings = false);
- virtual string Name(bool = false) { return varparser.varName; }
- virtual bool IsCondExpr() { return varparser.IsCondExpr(); }
- virtual bool IsShellCmd() { return varparser.IsShellCmd(); }
- virtual bool IsConnectCmd() { return varparser.IsConnectCmd(); }
- virtual bool IsLengthCmd() { return varparser.IsLengthCmd(); }
+ virtual string Name(bool = false) {
+ return varparser.varName;
+ }
+ virtual bool IsCondExpr() {
+ return varparser.IsCondExpr();
+ }
+ virtual bool IsShellCmd() {
+ return varparser.IsShellCmd();
+ }
+ virtual bool IsConnectCmd() {
+ return varparser.IsConnectCmd();
+ }
+ virtual bool IsLengthCmd() {
+ return varparser.IsLengthCmd();
+ }
bool DependsOnVar(const string& varName);
bool DependsOnVar(cUserVar* var);
bool AddDepVar(cUserVar* var);
void ResetCache();
};
-class cExtEPGVar : public cUserVar {
+class cExtEPGVar : public cUserVar
+{
const string name;
static string nameSpace;
- public:
+public:
cExtEPGVar(const string& Name) : name(Name) {}
- string Name(bool withNamespace = false) { return "%" + (withNamespace?nameSpace + ".":"") + name + "%"; }
- bool IsCondExpr() { return false; }
- bool IsShellCmd() { return false; }
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
-
- cSearchExtCat* SearchExtCat = SearchExtCats.First();
- while (SearchExtCat)
- {
- string varName = string("%") + SearchExtCat->name + string("%");
- int varPos = FindIgnoreCase(varName, Name());
- if (varPos == 0)
- {
- char* value = GetExtEPGValue(e, SearchExtCat);
- string res = value?value:"";
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- }
- return "";
- }
-};
-
-class cInternalVar : public cUserVar {
+ string Name(bool withNamespace = false) {
+ return "%" + (withNamespace ? nameSpace + "." : "") + name + "%";
+ }
+ bool IsCondExpr() {
+ return false;
+ }
+ bool IsShellCmd() {
+ return false;
+ }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+
+ cSearchExtCat* SearchExtCat = SearchExtCats.First();
+ while (SearchExtCat) {
+ string varName = string("%") + SearchExtCat->name + string("%");
+ int varPos = FindIgnoreCase(varName, Name());
+ if (varPos == 0) {
+ char* value = GetExtEPGValue(e, SearchExtCat);
+ string res = value ? value : "";
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ }
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ }
+ return "";
+ }
+};
+
+class cInternalVar : public cUserVar
+{
const string name;
- public:
+public:
cInternalVar(const string& Name) : name(Name) {}
- string Name(bool = false) { return "%" + name + "%"; }
- bool IsCondExpr() { return false; }
- bool IsShellCmd() { return false; }
-};
-
-class cTitleVar : public cInternalVar {
+ string Name(bool = false) {
+ return "%" + name + "%";
+ }
+ bool IsCondExpr() {
+ return false;
+ }
+ bool IsShellCmd() {
+ return false;
+ }
+};
+
+class cTitleVar : public cInternalVar
+{
public:
cTitleVar() : cInternalVar("title") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- string res = (e && !isempty(e->Title()))? e->Title() : "";
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ string res = (e && !isempty(e->Title())) ? e->Title() : "";
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ }
};
-class cSubtitleVar : public cInternalVar {
+class cSubtitleVar : public cInternalVar
+{
public:
cSubtitleVar() : cInternalVar("subtitle") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- string res = (e && !isempty(e->ShortText()))? e->ShortText() : "";
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ string res = (e && !isempty(e->ShortText())) ? e->ShortText() : "";
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ }
};
-class cSummaryVar : public cInternalVar {
+class cSummaryVar : public cInternalVar
+{
public:
cSummaryVar() : cInternalVar("summary") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- string res = (e && !isempty(e->Description()))? e->Description() : "";
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ string res = (e && !isempty(e->Description())) ? e->Description() : "";
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ }
};
-class cHTMLSummaryVar : public cInternalVar {
+class cHTMLSummaryVar : public cInternalVar
+{
public:
cHTMLSummaryVar() : cInternalVar("htmlsummary") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (e && !isempty(e->Description()))
- {
- string res = ReplaceAll(e->Description(), "\n", "<br />");
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
- else
- return "";
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (e && !isempty(e->Description())) {
+ string res = ReplaceAll(e->Description(), "\n", "<br />");
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ } else
+ return "";
+ }
};
-class cEventIDVar : public cInternalVar {
+class cEventIDVar : public cInternalVar
+{
public:
cEventIDVar() : cInternalVar("eventid") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (e)
- {
- ostringstream os;
- os << e->EventID();
- return os.str();
- }
- else return ""; }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (e) {
+ ostringstream os;
+ os << e->EventID();
+ return os.str();
+ } else return "";
+ }
};
-class cLiveEventIDVar : public cInternalVar {
+class cLiveEventIDVar : public cInternalVar
+{
public:
cLiveEventIDVar() : cInternalVar("liveeventid") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(e->ChannelID(), true);
- if (!channel) return "";
-
- string res(channel->GetChannelID().ToString());
- res = "event_" + res;
- res = ReplaceAll(res, ".", "p");
- res = ReplaceAll(res, "-", "m");
- res += "_" + NumToString(e->EventID());
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
-};
-
-class cTimeVar : public cInternalVar {
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(e->ChannelID(), true);
+ if (!channel) return "";
+
+ string res(channel->GetChannelID().ToString());
+ res = "event_" + res;
+ res = ReplaceAll(res, ".", "p");
+ res = ReplaceAll(res, "-", "m");
+ res += "_" + NumToString(e->EventID());
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ }
+};
+
+class cTimeVar : public cInternalVar
+{
public:
cTimeVar() : cInternalVar("time") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- string res = (e? *(e->GetTimeString()) : "");
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ string res = (e ? * (e->GetTimeString()) : "");
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ }
};
-class cTimeEndVar : public cInternalVar {
+class cTimeEndVar : public cInternalVar
+{
public:
cTimeEndVar() : cInternalVar("timeend") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- string res = (e? *(e->GetEndTimeString()) : "");
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ string res = (e ? * (e->GetEndTimeString()) : "");
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ }
};
-class cTime_wVar : public cInternalVar {
+class cTime_wVar : public cInternalVar
+{
public:
cTime_wVar() : cInternalVar("time_w") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- string res = (e? WEEKDAYNAME(e->StartTime()) : "");
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ string res = (e ? WEEKDAYNAME(e->StartTime()) : "");
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ }
};
-class cTime_dVar : public cInternalVar {
+class cTime_dVar : public cInternalVar
+{
public:
cTime_dVar() : cInternalVar("time_d") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- char day[3] = "";
- struct tm tm_r;
- const time_t t = e->StartTime();
- tm *tm = localtime_r(&t, &tm_r);
- strftime(day, sizeof(day), "%d", tm);
- if (escapeStrings) return "'" + EscapeString(day) + "'"; else return day;
- }
-};
-
-class cTime_lngVar : public cInternalVar {
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ char day[3] = "";
+ struct tm tm_r;
+ const time_t t = e->StartTime();
+ tm *tm = localtime_r(&t, &tm_r);
+ strftime(day, sizeof(day), "%d", tm);
+ if (escapeStrings) return "'" + EscapeString(day) + "'";
+ else return day;
+ }
+};
+
+class cTime_lngVar : public cInternalVar
+{
public:
cTime_lngVar() : cInternalVar("time_lng") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- ostringstream os;
- os << e->StartTime();
- if (escapeStrings) return "'" + EscapeString(os.str()) + "'"; else return os.str();
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ ostringstream os;
+ os << e->StartTime();
+ if (escapeStrings) return "'" + EscapeString(os.str()) + "'";
+ else return os.str();
+ }
};
-class cTimeSpanVar : public cInternalVar {
+class cTimeSpanVar : public cInternalVar
+{
public:
cTimeSpanVar() : cInternalVar("timespan") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- time_t diff = e->StartTime() - time(NULL);
- string res;
- if (labs(diff) >= SECSINDAY)
- {
- cString buffer;
- if (diff > 0)
- buffer = cString::sprintf(tr("in %02ldd"), long(diff / SECSINDAY));
- else
- buffer = cString::sprintf("%02ldd", long(-diff / SECSINDAY));
- res = buffer;
- }
- else if (labs(diff) >= (60 * 60))
- {
- cString buffer;
- if (diff > 0)
- buffer = cString::sprintf(tr("in %02ldh"), long(diff / (60*60)));
- else
- buffer = cString::sprintf("%02ldh", long(-diff / (60*60)));
- res = buffer;
- }
- else
- {
- cString buffer;
- if (diff > 0)
- buffer = cString::sprintf(tr("in %02ldm"), long(diff / 60));
- else
- buffer = cString::sprintf("%02ldm", long(-diff / 60));
- res = buffer;
- }
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
-};
-
-class cLength_Var : public cInternalVar {
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ time_t diff = e->StartTime() - time(NULL);
+ string res;
+ if (labs(diff) >= SECSINDAY) {
+ cString buffer;
+ if (diff > 0)
+ buffer = cString::sprintf(tr("in %02ldd"), long(diff / SECSINDAY));
+ else
+ buffer = cString::sprintf("%02ldd", long(-diff / SECSINDAY));
+ res = buffer;
+ } else if (labs(diff) >= (60 * 60)) {
+ cString buffer;
+ if (diff > 0)
+ buffer = cString::sprintf(tr("in %02ldh"), long(diff / (60 * 60)));
+ else
+ buffer = cString::sprintf("%02ldh", long(-diff / (60 * 60)));
+ res = buffer;
+ } else {
+ cString buffer;
+ if (diff > 0)
+ buffer = cString::sprintf(tr("in %02ldm"), long(diff / 60));
+ else
+ buffer = cString::sprintf("%02ldm", long(-diff / 60));
+ res = buffer;
+ }
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ }
+};
+
+class cLength_Var : public cInternalVar
+{
public:
cLength_Var() : cInternalVar("length") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- return (e? NumToString(e->Duration()) : "");
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ return (e ? NumToString(e->Duration()) : "");
+ }
};
-class cDateVar : public cInternalVar {
+class cDateVar : public cInternalVar
+{
public:
cDateVar() : cInternalVar("date") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- char date[9] = "";
- struct tm tm_r;
- const time_t t = e->StartTime();
- tm *tm = localtime_r(&t, &tm_r);
- strftime(date, sizeof(date), "%d.%m.%y", tm);
- if (escapeStrings) return "'" + EscapeString(date) + "'"; else return date;
- }
-};
-
-class cDateShortVar : public cInternalVar {
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ char date[9] = "";
+ struct tm tm_r;
+ const time_t t = e->StartTime();
+ tm *tm = localtime_r(&t, &tm_r);
+ strftime(date, sizeof(date), "%d.%m.%y", tm);
+ if (escapeStrings) return "'" + EscapeString(date) + "'";
+ else return date;
+ }
+};
+
+class cDateShortVar : public cInternalVar
+{
public:
cDateShortVar() : cInternalVar("datesh") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- char dateshort[7] = "";
- struct tm tm_r;
- const time_t t = e->StartTime();
- tm *tm = localtime_r(&t, &tm_r);
- strftime(dateshort, sizeof(dateshort), "%d.%m.", tm);
- if (escapeStrings) return "'" + EscapeString(dateshort) + "'"; else return dateshort;
- }
-};
-
-class cDateISOVar : public cInternalVar {
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ char dateshort[7] = "";
+ struct tm tm_r;
+ const time_t t = e->StartTime();
+ tm *tm = localtime_r(&t, &tm_r);
+ strftime(dateshort, sizeof(dateshort), "%d.%m.", tm);
+ if (escapeStrings) return "'" + EscapeString(dateshort) + "'";
+ else return dateshort;
+ }
+};
+
+class cDateISOVar : public cInternalVar
+{
public:
cDateISOVar() : cInternalVar("date_iso") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- char dateISO[11] = "";
- struct tm tm_r;
- const time_t t = e->StartTime();
- tm *tm = localtime_r(&t, &tm_r);
- strftime(dateISO, sizeof(dateISO), "%Y-%m-%d", tm);
- if (escapeStrings) return "'" + EscapeString(dateISO) + "'"; else return dateISO;
- }
-};
-
-class cYearVar : public cInternalVar {
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ char dateISO[11] = "";
+ struct tm tm_r;
+ const time_t t = e->StartTime();
+ tm *tm = localtime_r(&t, &tm_r);
+ strftime(dateISO, sizeof(dateISO), "%Y-%m-%d", tm);
+ if (escapeStrings) return "'" + EscapeString(dateISO) + "'";
+ else return dateISO;
+ }
+};
+
+class cYearVar : public cInternalVar
+{
public:
cYearVar() : cInternalVar("year") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- char year[5] = "";
- struct tm tm_r;
- const time_t t = e->StartTime();
- tm *tm = localtime_r(&t, &tm_r);
- strftime(year, sizeof(year), "%Y", tm);
- if (escapeStrings) return "'" + EscapeString(year) + "'"; else return year;
- }
-};
-
-class cMonthVar : public cInternalVar {
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ char year[5] = "";
+ struct tm tm_r;
+ const time_t t = e->StartTime();
+ tm *tm = localtime_r(&t, &tm_r);
+ strftime(year, sizeof(year), "%Y", tm);
+ if (escapeStrings) return "'" + EscapeString(year) + "'";
+ else return year;
+ }
+};
+
+class cMonthVar : public cInternalVar
+{
public:
cMonthVar() : cInternalVar("month") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- char month[3] = "";
- struct tm tm_r;
- const time_t t = e->StartTime();
- tm *tm = localtime_r(&t, &tm_r);
- strftime(month, sizeof(month), "%m", tm);
- if (escapeStrings) return "'" + EscapeString(month) + "'"; else return month;
- }
-};
-
-class cDayVar : public cInternalVar {
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ char month[3] = "";
+ struct tm tm_r;
+ const time_t t = e->StartTime();
+ tm *tm = localtime_r(&t, &tm_r);
+ strftime(month, sizeof(month), "%m", tm);
+ if (escapeStrings) return "'" + EscapeString(month) + "'";
+ else return month;
+ }
+};
+
+class cDayVar : public cInternalVar
+{
public:
cDayVar() : cInternalVar("day") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- char day[3] = "";
- struct tm tm_r;
- const time_t t = e->StartTime();
- tm *tm = localtime_r(&t, &tm_r);
- strftime(day, sizeof(day), "%d", tm);
- if (escapeStrings) return "'" + EscapeString(day) + "'"; else return day;
- }
-};
-
-class cWeekVar : public cInternalVar {
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ char day[3] = "";
+ struct tm tm_r;
+ const time_t t = e->StartTime();
+ tm *tm = localtime_r(&t, &tm_r);
+ strftime(day, sizeof(day), "%d", tm);
+ if (escapeStrings) return "'" + EscapeString(day) + "'";
+ else return day;
+ }
+};
+
+class cWeekVar : public cInternalVar
+{
public:
cWeekVar() : cInternalVar("week") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- char day[3] = "";
- struct tm tm_r;
- const time_t t = e->StartTime();
- tm *tm = localtime_r(&t, &tm_r);
- strftime(day, sizeof(day), "%V", tm);
- if (escapeStrings) return "'" + EscapeString(day) + "'"; else return day;
- }
-};
-
-class cChannelNrVar : public cInternalVar {
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ char day[3] = "";
+ struct tm tm_r;
+ const time_t t = e->StartTime();
+ tm *tm = localtime_r(&t, &tm_r);
+ strftime(day, sizeof(day), "%V", tm);
+ if (escapeStrings) return "'" + EscapeString(day) + "'";
+ else return day;
+ }
+};
+
+class cChannelNrVar : public cInternalVar
+{
public:
cChannelNrVar() : cInternalVar("chnr") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- int chnr = ChannelNrFromEvent(e);
- if (chnr < 0) return "";
- return NumToString(chnr);
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ int chnr = ChannelNrFromEvent(e);
+ if (chnr < 0) return "";
+ return NumToString(chnr);
+ }
};
-class cChannelShortVar : public cInternalVar {
+class cChannelShortVar : public cInternalVar
+{
public:
cChannelShortVar() : cInternalVar("chsh") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(e->ChannelID(), true);
- string res = channel?channel->ShortName(true):"";
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(e->ChannelID(), true);
+ string res = channel ? channel->ShortName(true) : "";
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ }
};
-class cChannelLongVar : public cInternalVar {
+class cChannelLongVar : public cInternalVar
+{
public:
cChannelLongVar() : cInternalVar("chlng") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(e->ChannelID(), true);
- string res = channel?channel->Name():"";
- if (escapeStrings) return "'" + EscapeString(res) + "'"; else return res;
- }
-};
-
-class cChannelDataVar : public cInternalVar {
- public:
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(e->ChannelID(), true);
+ string res = channel ? channel->Name() : "";
+ if (escapeStrings) return "'" + EscapeString(res) + "'";
+ else return res;
+ }
+};
+
+class cChannelDataVar : public cInternalVar
+{
+public:
cChannelDataVar() : cInternalVar("chdata") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(e->ChannelID(), true);
- return channel?CHANNELSTRING(channel):"";
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(e->ChannelID(), true);
+ return channel ? CHANNELSTRING(channel) : "";
+ }
};
-class cChannelGroupVar : public cInternalVar {
+class cChannelGroupVar : public cInternalVar
+{
public:
cChannelGroupVar() : cInternalVar("chgrp") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- ostringstream os;
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(e->ChannelID(), true);
- while(channel && !channel->GroupSep())
- channel = Channels->Prev(channel);
- if (!channel || !channel->Name()) return "";
- string grpName = channel->Name();
- if (escapeStrings) return "'" + EscapeString(grpName) + "'"; else return grpName;
- }
-};
-
-class cNEWTCmdVar : public cInternalVar {
- public:
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ ostringstream os;
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(e->ChannelID(), true);
+ while (channel && !channel->GroupSep())
+ channel = Channels->Prev(channel);
+ if (!channel || !channel->Name()) return "";
+ string grpName = channel->Name();
+ if (escapeStrings) return "'" + EscapeString(grpName) + "'";
+ else return grpName;
+ }
+};
+
+class cNEWTCmdVar : public cInternalVar
+{
+public:
cNEWTCmdVar() : cInternalVar("newtcmd") {}
- string Evaluate(const cEvent* e, bool escapeStrings = false)
- {
- if (!e) return "";
- cTimer* timer = new cTimer(e);
- string newtCmd = *(timer->ToText());
- if (escapeStrings) return "'" + EscapeString(newtCmd) + "'"; else return newtCmd;
- }
+ string Evaluate(const cEvent* e, bool escapeStrings = false) {
+ if (!e) return "";
+ cTimer* timer = new cTimer(e);
+ string newtCmd = *(timer->ToText());
+ if (escapeStrings) return "'" + EscapeString(newtCmd) + "'";
+ else return newtCmd;
+ }
};
// independet variables
-class cColonVar : public cInternalVar {
- public:
+class cColonVar : public cInternalVar
+{
+public:
cColonVar() : cInternalVar("colon") {}
- string Evaluate(const cEvent*, bool escapeStrings = false)
- {
- return ":";
- }
+ string Evaluate(const cEvent*, bool escapeStrings = false) {
+ return ":";
+ }
};
-class cDateNowVar : public cInternalVar {
- public:
+class cDateNowVar : public cInternalVar
+{
+public:
cDateNowVar() : cInternalVar("datenow") {}
- string Evaluate(const cEvent*, bool escapeStrings = false)
- {
- char date[9] = "";
- struct tm tm_r;
- const time_t t = time(NULL);
- tm *tm = localtime_r(&t, &tm_r);
- strftime(date, sizeof(date), "%d.%m.%y", tm);
- if (escapeStrings) return "'" + EscapeString(date) + "'"; else return date;
- }
-};
-
-class cDateShortNowVar : public cInternalVar {
+ string Evaluate(const cEvent*, bool escapeStrings = false) {
+ char date[9] = "";
+ struct tm tm_r;
+ const time_t t = time(NULL);
+ tm *tm = localtime_r(&t, &tm_r);
+ strftime(date, sizeof(date), "%d.%m.%y", tm);
+ if (escapeStrings) return "'" + EscapeString(date) + "'";
+ else return date;
+ }
+};
+
+class cDateShortNowVar : public cInternalVar
+{
public:
cDateShortNowVar() : cInternalVar("dateshnow") {}
- string Evaluate(const cEvent*, bool escapeStrings = false)
- {
- char dateshort[7] = "";
- struct tm tm_r;
- const time_t t = time(NULL);
- tm *tm = localtime_r(&t, &tm_r);
- strftime(dateshort, sizeof(dateshort), "%d.%m.", tm);
- if (escapeStrings) return "'" + EscapeString(dateshort) + "'"; else return dateshort;
- }
-};
-
-class cDateISONowVar : public cInternalVar {
+ string Evaluate(const cEvent*, bool escapeStrings = false) {
+ char dateshort[7] = "";
+ struct tm tm_r;
+ const time_t t = time(NULL);
+ tm *tm = localtime_r(&t, &tm_r);
+ strftime(dateshort, sizeof(dateshort), "%d.%m.", tm);
+ if (escapeStrings) return "'" + EscapeString(dateshort) + "'";
+ else return dateshort;
+ }
+};
+
+class cDateISONowVar : public cInternalVar
+{
public:
cDateISONowVar() : cInternalVar("date_iso_now") {}
- string Evaluate(const cEvent*, bool escapeStrings = false)
- {
- char dateISO[11] = "";
- struct tm tm_r;
- const time_t t = time(NULL);
- tm *tm = localtime_r(&t, &tm_r);
- strftime(dateISO, sizeof(dateISO), "%Y-%m-%d", tm);
- if (escapeStrings) return "'" + EscapeString(dateISO) + "'"; else return dateISO;
- }
-};
-
-class cTimeNowVar : public cInternalVar {
+ string Evaluate(const cEvent*, bool escapeStrings = false) {
+ char dateISO[11] = "";
+ struct tm tm_r;
+ const time_t t = time(NULL);
+ tm *tm = localtime_r(&t, &tm_r);
+ strftime(dateISO, sizeof(dateISO), "%Y-%m-%d", tm);
+ if (escapeStrings) return "'" + EscapeString(dateISO) + "'";
+ else return dateISO;
+ }
+};
+
+class cTimeNowVar : public cInternalVar
+{
public:
cTimeNowVar() : cInternalVar("timenow") {}
- string Evaluate(const cEvent*, bool escapeStrings = false)
- {
- return TIMESTRING(time(NULL));
- }
+ string Evaluate(const cEvent*, bool escapeStrings = false) {
+ return TIMESTRING(time(NULL));
+ }
};
-class cVideodirVar : public cInternalVar {
- public:
+class cVideodirVar : public cInternalVar
+{
+public:
cVideodirVar() : cInternalVar("videodir") {}
- string Evaluate(const cEvent*, bool escapeStrings = false)
- {
- return cVideoDirectory::Name();
- }
+ string Evaluate(const cEvent*, bool escapeStrings = false) {
+ return cVideoDirectory::Name();
+ }
};
-class cPlugconfdirVar : public cInternalVar {
- public:
+class cPlugconfdirVar : public cInternalVar
+{
+public:
static string dir;
cPlugconfdirVar() : cInternalVar("plugconfdir") {}
- string Evaluate(const cEvent*, bool escapeStrings = false)
- {
- return dir;
- }
+ string Evaluate(const cEvent*, bool escapeStrings = false) {
+ return dir;
+ }
};
-class cEpgsearchconfdirVar : public cInternalVar {
- public:
+class cEpgsearchconfdirVar : public cInternalVar
+{
+public:
static string dir;
cEpgsearchconfdirVar() : cInternalVar("epgsearchdir") {}
- string Evaluate(const cEvent*, bool escapeStrings = false)
- {
- return CONFIGDIR;
- }
+ string Evaluate(const cEvent*, bool escapeStrings = false) {
+ return CONFIGDIR;
+ }
};
// timer variables
-class cTimerVar {
+class cTimerVar
+{
static string nameSpace;
const string name;
- public:
+public:
cTimerVar(const string& Name) : name(Name) {}
virtual ~cTimerVar() {}
- string Name() { return "%" + nameSpace + "." + name + "%"; }
+ string Name() {
+ return "%" + nameSpace + "." + name + "%";
+ }
virtual string Evaluate(const cTimer* t) = 0;
};
-class cTimerDateVar : public cTimerVar {
- public:
+class cTimerDateVar : public cTimerVar
+{
+public:
cTimerDateVar() : cTimerVar("date") {}
- string Evaluate(const cTimer* t)
- {
- if (!t) return "";
- return DATESTRING(t->StartTime());
- }
+ string Evaluate(const cTimer* t) {
+ if (!t) return "";
+ return DATESTRING(t->StartTime());
+ }
};
-class cTimerStartVar : public cTimerVar {
- public:
+class cTimerStartVar : public cTimerVar
+{
+public:
cTimerStartVar() : cTimerVar("start") {}
- string Evaluate(const cTimer* t)
- {
- if (!t) return "";
- return TIMESTRING(t->StartTime());
- }
+ string Evaluate(const cTimer* t) {
+ if (!t) return "";
+ return TIMESTRING(t->StartTime());
+ }
};
-class cTimerStopVar : public cTimerVar {
- public:
+class cTimerStopVar : public cTimerVar
+{
+public:
cTimerStopVar() : cTimerVar("stop") {}
- string Evaluate(const cTimer* t)
- {
- if (!t) return "";
- return TIMESTRING(t->StopTime());
- }
+ string Evaluate(const cTimer* t) {
+ if (!t) return "";
+ return TIMESTRING(t->StopTime());
+ }
};
-class cTimerFileVar : public cTimerVar {
- public:
+class cTimerFileVar : public cTimerVar
+{
+public:
cTimerFileVar() : cTimerVar("file") {}
- string Evaluate(const cTimer* t)
- {
- if (!t) return "";
- return t->File();
- }
+ string Evaluate(const cTimer* t) {
+ if (!t) return "";
+ return t->File();
+ }
};
-class cTimerChnrVar : public cTimerVar {
- public:
+class cTimerChnrVar : public cTimerVar
+{
+public:
cTimerChnrVar() : cTimerVar("chnr") {}
- string Evaluate(const cTimer* t)
- {
- if (!t || !t->Channel()) return "";
- return NumToString(t->Channel()->Number());
- }
+ string Evaluate(const cTimer* t) {
+ if (!t || !t->Channel()) return "";
+ return NumToString(t->Channel()->Number());
+ }
};
-class cTimerChannelShortVar : public cTimerVar {
+class cTimerChannelShortVar : public cTimerVar
+{
public:
cTimerChannelShortVar() : cTimerVar("chsh") {}
- string Evaluate(const cTimer* t)
- {
- if (!t || !t->Channel()) return "";
- return t->Channel()->ShortName(true);
- }
+ string Evaluate(const cTimer* t) {
+ if (!t || !t->Channel()) return "";
+ return t->Channel()->ShortName(true);
+ }
};
-class cTimerChannelLongVar : public cTimerVar {
+class cTimerChannelLongVar : public cTimerVar
+{
public:
cTimerChannelLongVar() : cTimerVar("chlng") {}
- string Evaluate(const cTimer* t)
- {
- if (!t || !t->Channel()) return "";
- return t->Channel()->Name();
- }
+ string Evaluate(const cTimer* t) {
+ if (!t || !t->Channel()) return "";
+ return t->Channel()->Name();
+ }
};
-class cTimerSearchVar : public cTimerVar {
- public:
+class cTimerSearchVar : public cTimerVar
+{
+public:
cTimerSearchVar() : cTimerVar("search") {}
- string Evaluate(const cTimer* t)
- {
- if (!t) return "";
- cSearchExt* s = TriggeredFromSearchTimer(t);
- if (!s) return "";
- return s->search;
- }
+ string Evaluate(const cTimer* t) {
+ if (!t) return "";
+ cSearchExt* s = TriggeredFromSearchTimer(t);
+ if (!s) return "";
+ return s->search;
+ }
};
-class cTimerSearchIDVar : public cTimerVar {
- public:
+class cTimerSearchIDVar : public cTimerVar
+{
+public:
cTimerSearchIDVar() : cTimerVar("searchid") {}
- string Evaluate(const cTimer* t)
- {
- if (!t) return "";
- int ID = TriggeredFromSearchTimerID(t);
- if (ID < 0) return "";
- return NumToString(ID);
- }
+ string Evaluate(const cTimer* t) {
+ if (!t) return "";
+ int ID = TriggeredFromSearchTimerID(t);
+ if (ID < 0) return "";
+ return NumToString(ID);
+ }
};
-class cTimerLiveIDVar : public cTimerVar {
+class cTimerLiveIDVar : public cTimerVar
+{
public:
cTimerLiveIDVar() : cTimerVar("liveid") {}
- string Evaluate(const cTimer* t)
- {
- if (!t || !t->Channel()) return "";
- ostringstream builder;
- builder << *(t->Channel()->GetChannelID().ToString()) << ":" << t->WeekDays() << ":"
- << t->Day() << ":" << t->Start() << ":" << t->Stop();
- string res = builder.str();
- res = "timer_" + res;
- res = ReplaceAll(res, ".", "p");
- res = ReplaceAll(res, "-", "m");
- res = ReplaceAll(res, ":", "c");
- return res;
- }
+ string Evaluate(const cTimer* t) {
+ if (!t || !t->Channel()) return "";
+ ostringstream builder;
+ builder << *(t->Channel()->GetChannelID().ToString()) << ":" << t->WeekDays() << ":"
+ << t->Day() << ":" << t->Start() << ":" << t->Stop();
+ string res = builder.str();
+ res = "timer_" + res;
+ res = ReplaceAll(res, ".", "p");
+ res = ReplaceAll(res, "-", "m");
+ res = ReplaceAll(res, ":", "c");
+ return res;
+ }
};
// search variables
-class cSearchVar {
+class cSearchVar
+{
const string name;
static string nameSpace;
- public:
+public:
cSearchVar(const string& Name) : name(Name) {}
virtual ~cSearchVar() {}
- string Name() { return "%" + nameSpace + "." + name + "%"; }
+ string Name() {
+ return "%" + nameSpace + "." + name + "%";
+ }
virtual string Evaluate(const cSearchExt* s) = 0;
};
-class cSearchQueryVar : public cSearchVar {
+class cSearchQueryVar : public cSearchVar
+{
public:
cSearchQueryVar() : cSearchVar("query") {}
- string Evaluate(const cSearchExt* s)
- {
- if (!s) return "";
- return s->search;
- }
+ string Evaluate(const cSearchExt* s) {
+ if (!s) return "";
+ return s->search;
+ }
};
-class cSearchSeriesVar : public cSearchVar {
+class cSearchSeriesVar : public cSearchVar
+{
public:
cSearchSeriesVar() : cSearchVar("series") {}
- string Evaluate(const cSearchExt* s)
- {
- if (!s) return "";
- return NumToString(s->useEpisode);
- }
+ string Evaluate(const cSearchExt* s) {
+ if (!s) return "";
+ return NumToString(s->useEpisode);
+ }
};
-class cUserVars : public cList<cUserVar> {
- public:
+class cUserVars : public cList<cUserVar>
+{
+public:
cTitleVar titleVar;
cSubtitleVar subtitleVar;
cSummaryVar summaryVar;
@@ -778,113 +825,110 @@ class cUserVars : public cList<cUserVar> {
map<string, cTimerVar*> internalTimerVars;
map<string, cSearchVar*> internalSearchVars;
- void InitInternalVars()
- {
- internalVars[titleVar.Name()] = &titleVar;
- internalVars[subtitleVar.Name()] = &subtitleVar;
- internalVars[summaryVar.Name()] = &summaryVar;
- internalVars[htmlsummaryVar.Name()] = &htmlsummaryVar;
- internalVars[eventIDVar.Name()] = &eventIDVar;
- internalVars[liveeventIDVar.Name()] = &liveeventIDVar;
- internalVars[timeVar.Name()] = &timeVar;
- internalVars[timeEndVar.Name()] = &timeEndVar;
- internalVars[time_wVar.Name()] = &time_wVar;
- internalVars[time_dVar.Name()] = &time_dVar;
- internalVars[time_lngVar.Name()] = &time_lngVar;
- internalVars[time_spanVar.Name()] = &time_spanVar;
- internalVars[length_Var.Name()] = &length_Var;
- internalVars[dateVar.Name()] = &dateVar;
- internalVars[dateShortVar.Name()] = &dateShortVar;
- internalVars[dateISOVar.Name()] = &dateISOVar;
- internalVars[yearVar.Name()] = &yearVar;
- internalVars[monthVar.Name()] = &monthVar;
- internalVars[dayVar.Name()] = &dayVar;
- internalVars[weekVar.Name()] = &weekVar;
- internalVars[chnrVar.Name()] = &chnrVar;
- internalVars[chShortVar.Name()] = &chShortVar;
- internalVars[chLongVar.Name()] = &chLongVar;
- internalVars[chDataVar.Name()] = &chDataVar;
- internalVars[chGroupVar.Name()] = &chGroupVar;
- internalVars[newtCmdVar.Name()] = &newtCmdVar;
-
- internalVars[colonVar.Name()] = &colonVar;
- internalVars[dateNowVar.Name()] = &dateNowVar;
- internalVars[dateShortNowVar.Name()] = &dateShortNowVar;
- internalVars[dateISONowVar.Name()] = &dateISONowVar;
- internalVars[timeNowVar.Name()] = &timeNowVar;
- internalVars[videodirVar.Name()] = &videodirVar;
- internalVars[plugconfdirVar.Name()] = &plugconfdirVar;
- internalVars[epgsearchconfdirVar.Name()] = &epgsearchconfdirVar;
-
- internalTimerVars[timerDateVar.Name()] = &timerDateVar;
- internalTimerVars[timerStartVar.Name()] = &timerStartVar;
- internalTimerVars[timerStopVar.Name()] = &timerStopVar;
- internalTimerVars[timerFileVar.Name()] = &timerFileVar;
- internalTimerVars[timerChnrVar.Name()] = &timerChnrVar;
- internalTimerVars[timerChShortVar.Name()] = &timerChShortVar;
- internalTimerVars[timerChLongVar.Name()] = &timerChLongVar;
- internalTimerVars[timerSearchVar.Name()] = &timerSearchVar;
- internalTimerVars[timerSearchIDVar.Name()] = &timerSearchIDVar;
- internalTimerVars[timerLiveIDVar.Name()] = &timerLiveIDVar;
-
- internalSearchVars[searchQueryVar.Name()] = &searchQueryVar;
- internalSearchVars[searchSeriesVar.Name()] = &searchSeriesVar;
- }
-
- void InitExtEPGVars()
- {
- cSearchExtCat* SearchExtCat = SearchExtCats.First();
- while (SearchExtCat)
- {
- string varName = SearchExtCat->name;
- std::transform(varName.begin(), varName.end(), varName.begin(), tolower);
- cExtEPGVar* extEPGVar = new cExtEPGVar(varName);
- extEPGVars[extEPGVar->Name()] = extEPGVar;
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- }
- }
- void ResetCache()
- {
- cUserVar* var = First();
- while (var)
- {
- var->ResetCache();
- var = Next(var);
- }
- }
- ~cUserVars()
- {
- std::map<string, cExtEPGVar*>::iterator evar;
- for (evar = extEPGVars.begin(); evar != extEPGVars.end(); ++evar)
- delete evar->second;
- extEPGVars.clear();
-
- std::set<cUserVar*>::iterator uvar;
- for (uvar = userVars.begin(); uvar != userVars.end(); ++uvar)
- delete (*uvar);
- userVars.clear();
- }
+ void InitInternalVars() {
+ internalVars[titleVar.Name()] = &titleVar;
+ internalVars[subtitleVar.Name()] = &subtitleVar;
+ internalVars[summaryVar.Name()] = &summaryVar;
+ internalVars[htmlsummaryVar.Name()] = &htmlsummaryVar;
+ internalVars[eventIDVar.Name()] = &eventIDVar;
+ internalVars[liveeventIDVar.Name()] = &liveeventIDVar;
+ internalVars[timeVar.Name()] = &timeVar;
+ internalVars[timeEndVar.Name()] = &timeEndVar;
+ internalVars[time_wVar.Name()] = &time_wVar;
+ internalVars[time_dVar.Name()] = &time_dVar;
+ internalVars[time_lngVar.Name()] = &time_lngVar;
+ internalVars[time_spanVar.Name()] = &time_spanVar;
+ internalVars[length_Var.Name()] = &length_Var;
+ internalVars[dateVar.Name()] = &dateVar;
+ internalVars[dateShortVar.Name()] = &dateShortVar;
+ internalVars[dateISOVar.Name()] = &dateISOVar;
+ internalVars[yearVar.Name()] = &yearVar;
+ internalVars[monthVar.Name()] = &monthVar;
+ internalVars[dayVar.Name()] = &dayVar;
+ internalVars[weekVar.Name()] = &weekVar;
+ internalVars[chnrVar.Name()] = &chnrVar;
+ internalVars[chShortVar.Name()] = &chShortVar;
+ internalVars[chLongVar.Name()] = &chLongVar;
+ internalVars[chDataVar.Name()] = &chDataVar;
+ internalVars[chGroupVar.Name()] = &chGroupVar;
+ internalVars[newtCmdVar.Name()] = &newtCmdVar;
+
+ internalVars[colonVar.Name()] = &colonVar;
+ internalVars[dateNowVar.Name()] = &dateNowVar;
+ internalVars[dateShortNowVar.Name()] = &dateShortNowVar;
+ internalVars[dateISONowVar.Name()] = &dateISONowVar;
+ internalVars[timeNowVar.Name()] = &timeNowVar;
+ internalVars[videodirVar.Name()] = &videodirVar;
+ internalVars[plugconfdirVar.Name()] = &plugconfdirVar;
+ internalVars[epgsearchconfdirVar.Name()] = &epgsearchconfdirVar;
+
+ internalTimerVars[timerDateVar.Name()] = &timerDateVar;
+ internalTimerVars[timerStartVar.Name()] = &timerStartVar;
+ internalTimerVars[timerStopVar.Name()] = &timerStopVar;
+ internalTimerVars[timerFileVar.Name()] = &timerFileVar;
+ internalTimerVars[timerChnrVar.Name()] = &timerChnrVar;
+ internalTimerVars[timerChShortVar.Name()] = &timerChShortVar;
+ internalTimerVars[timerChLongVar.Name()] = &timerChLongVar;
+ internalTimerVars[timerSearchVar.Name()] = &timerSearchVar;
+ internalTimerVars[timerSearchIDVar.Name()] = &timerSearchIDVar;
+ internalTimerVars[timerLiveIDVar.Name()] = &timerLiveIDVar;
+
+ internalSearchVars[searchQueryVar.Name()] = &searchQueryVar;
+ internalSearchVars[searchSeriesVar.Name()] = &searchSeriesVar;
+ }
+
+ void InitExtEPGVars() {
+ cSearchExtCat* SearchExtCat = SearchExtCats.First();
+ while (SearchExtCat) {
+ string varName = SearchExtCat->name;
+ std::transform(varName.begin(), varName.end(), varName.begin(), tolower);
+ cExtEPGVar* extEPGVar = new cExtEPGVar(varName);
+ extEPGVars[extEPGVar->Name()] = extEPGVar;
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ }
+ }
+ void ResetCache() {
+ cUserVar* var = First();
+ while (var) {
+ var->ResetCache();
+ var = Next(var);
+ }
+ }
+ ~cUserVars() {
+ std::map<string, cExtEPGVar*>::iterator evar;
+ for (evar = extEPGVars.begin(); evar != extEPGVars.end(); ++evar)
+ delete evar->second;
+ extEPGVars.clear();
+
+ std::set<cUserVar*>::iterator uvar;
+ for (uvar = userVars.begin(); uvar != userVars.end(); ++uvar)
+ delete(*uvar);
+ userVars.clear();
+ }
cUserVar* GetFromName(const string& varName, bool log = true);
};
extern cUserVars UserVars;
-class cUserVarLine : public cListObject {
+class cUserVarLine : public cListObject
+{
public:
- static bool Parse(char *s);
+ static bool Parse(char *s);
};
class cUserVarFile : public cConfig<cUserVarLine>
{
public:
- cUserVarFile() { UserVars.Clear(); };
+ cUserVarFile() {
+ UserVars.Clear();
+ };
};
class cVarExpr
{
string expr;
- public:
+public:
set<cUserVar*> usedVars;
cVarExpr(const string& Expr) : expr(Expr) {}
string Evaluate(const cEvent* e = NULL);
diff --git a/varparser.c b/varparser.c
index 1f2ea07..a565dae 100644
--- a/varparser.c
+++ b/varparser.c
@@ -29,211 +29,197 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
bool cVarParser::Parse(const string& input)
{
- return ParseAssign(input);
+ return ParseAssign(input);
}
bool cVarParser::ParseAssign(const string& input)
{
- int assignPos = input.find("=");
- if (assignPos >= 0)
- {
- string var(input.begin(), input.begin() + assignPos);
- if (ParseVar(var))
- {
- varName = Strip(var);
- string assign(input.begin() + assignPos + 1, input.end());
- return ParseExp(assign);
- }
- }
- LogFile.eSysLog("error parsing '%s'", input.c_str());
- return false;
+ int assignPos = input.find("=");
+ if (assignPos >= 0) {
+ string var(input.begin(), input.begin() + assignPos);
+ if (ParseVar(var)) {
+ varName = Strip(var);
+ string assign(input.begin() + assignPos + 1, input.end());
+ return ParseExp(assign);
+ }
+ }
+ LogFile.eSysLog("error parsing '%s'", input.c_str());
+ return false;
}
bool cVarParser::ParseExp(const string& input)
{
- // system call?
- int sysPos = input.find("system");
- if (sysPos == 0)
- return ParseShellCmd(input);
- // connect command?
- int conPos = input.find("connect");
- if (conPos == 0)
- return ParseConnectCmd(input);
- // length command?
- int lenPos = input.find("length");
- if (lenPos == 0)
- return ParseLengthCmd(input);
- // conditional expression?
- int varPos = Strip(input).find("%");
- if (varPos == 0)
- {
- int queryPos = input.find("?");
- if (queryPos >= 0)
- {
- int colonPos = input.find(":");
- if (colonPos > queryPos)
- return ParseCondExp(input);
- }
- }
- // composed expression
- compExpr = input;
- return true;
+ // system call?
+ int sysPos = input.find("system");
+ if (sysPos == 0)
+ return ParseShellCmd(input);
+ // connect command?
+ int conPos = input.find("connect");
+ if (conPos == 0)
+ return ParseConnectCmd(input);
+ // length command?
+ int lenPos = input.find("length");
+ if (lenPos == 0)
+ return ParseLengthCmd(input);
+ // conditional expression?
+ int varPos = Strip(input).find("%");
+ if (varPos == 0) {
+ int queryPos = input.find("?");
+ if (queryPos >= 0) {
+ int colonPos = input.find(":");
+ if (colonPos > queryPos)
+ return ParseCondExp(input);
+ }
+ }
+ // composed expression
+ compExpr = input;
+ return true;
}
bool cVarParser::ParseShellCmd(const string& input)
{
- int cmdPos = input.find("(");
- int cmdArgsBegin = input.find(",");
- int cmdArgsEnd = input.rfind(")");
- if (cmdPos == -1 || cmdArgsEnd == -1) return false;
- string shellcmd(input.begin() + cmdPos + 1, input.begin() + (cmdArgsBegin >= 0?cmdArgsBegin:cmdArgsEnd));
- shellcmd = Strip(shellcmd);
-
- cmdArgs = "";
- if (cmdArgsBegin >= 0)
- cmdArgs = string(input.begin() + cmdArgsBegin + 1, input.begin() + cmdArgsEnd);
-
- string cmdVDR = "varcmd: " + shellcmd;
- cmd = new cCommand;
- if (!cmd->Parse(cmdVDR.c_str()))
- {
- LogFile.eSysLog("error parsing command: %s", input.c_str());
- delete cmd;
- cmd = NULL;
- return false;
- }
- type = cVarParser::shellcmd;
- return true;
+ int cmdPos = input.find("(");
+ int cmdArgsBegin = input.find(",");
+ int cmdArgsEnd = input.rfind(")");
+ if (cmdPos == -1 || cmdArgsEnd == -1) return false;
+ string shellcmd(input.begin() + cmdPos + 1, input.begin() + (cmdArgsBegin >= 0 ? cmdArgsBegin : cmdArgsEnd));
+ shellcmd = Strip(shellcmd);
+
+ cmdArgs = "";
+ if (cmdArgsBegin >= 0)
+ cmdArgs = string(input.begin() + cmdArgsBegin + 1, input.begin() + cmdArgsEnd);
+
+ string cmdVDR = "varcmd: " + shellcmd;
+ cmd = new cCommand;
+ if (!cmd->Parse(cmdVDR.c_str())) {
+ LogFile.eSysLog("error parsing command: %s", input.c_str());
+ delete cmd;
+ cmd = NULL;
+ return false;
+ }
+ type = cVarParser::shellcmd;
+ return true;
}
bool cVarParser::ParseConnectCmd(const string& input)
{
- int startCon = input.find("(");
- int endCon = input.find(")");
- if (startCon == -1 || endCon == -1) return false;
- string connect(input.begin() + startCon + 1, input.begin() + endCon);
- std::stringstream ss(connect);
- std::string item;
- if (std::getline(ss, item, ','))
- connectAddr = item;
- if (std::getline(ss, item, ','))
- connectPort = atoi(item.c_str());
- if (std::getline(ss, item))
- cmdArgs = item;
-
- connectAddr = Strip(connectAddr);
- cmdArgs = Strip(cmdArgs);
-
- if (connectAddr.size() == 0 || connectPort == -1)
- {
- LogFile.eSysLog("error parsing command: %s", input.c_str());
- return false;
- }
- type = cVarParser::connectcmd;
- return true;
+ int startCon = input.find("(");
+ int endCon = input.find(")");
+ if (startCon == -1 || endCon == -1) return false;
+ string connect(input.begin() + startCon + 1, input.begin() + endCon);
+ std::stringstream ss(connect);
+ std::string item;
+ if (std::getline(ss, item, ','))
+ connectAddr = item;
+ if (std::getline(ss, item, ','))
+ connectPort = atoi(item.c_str());
+ if (std::getline(ss, item))
+ cmdArgs = item;
+
+ connectAddr = Strip(connectAddr);
+ cmdArgs = Strip(cmdArgs);
+
+ if (connectAddr.size() == 0 || connectPort == -1) {
+ LogFile.eSysLog("error parsing command: %s", input.c_str());
+ return false;
+ }
+ type = cVarParser::connectcmd;
+ return true;
}
bool cVarParser::ParseLengthCmd(const string& input)
{
- int startLen = input.find("(");
- int endLen = input.find(")");
- if (startLen == -1 || endLen == -1) return false;
- string arg(input.begin() + startLen + 1, input.begin() + endLen);
- compExpr = arg;
- type = cVarParser::lengthcmd;
- return true;
+ int startLen = input.find("(");
+ int endLen = input.find(")");
+ if (startLen == -1 || endLen == -1) return false;
+ string arg(input.begin() + startLen + 1, input.begin() + endLen);
+ compExpr = arg;
+ type = cVarParser::lengthcmd;
+ return true;
}
bool cVarParser::ParseCondExp(const string& input)
{
- int condEndPos = input.find("?");
- string cond(input.begin(), input.begin() + condEndPos);
- int condNeqPos = cond.find("!=");
- int condEqPos = cond.find("==");
-
- if (condEqPos == -1 && condNeqPos == -1)
- {
- cond += "!=";
- condNeqPos = cond.find("!=");
- }
-
- if (condEqPos >= 0 || condNeqPos >= 0)
- {
- if (!ParseEquality(cond))
- {
- LogFile.eSysLog("error parsing '%s'", input.c_str());
- return false;
- }
- condOp = (condEqPos >= 0)?condEq:condNeq;
- }
- else
- {
- LogFile.eSysLog("error parsing '%s'", input.c_str());
- return false;
- }
-
- string truefalse(input.begin() + condEndPos + 1, input.end());
- int elsePos = truefalse.find(":");
- if (elsePos >= 0)
- {
- string truePart(truefalse.begin(), truefalse.begin() + elsePos);
- string falsePart(truefalse.begin() + elsePos + 1, truefalse.end());
- if (ParseVar(truePart) && ParseVar(falsePart))
- {
- condvarTrue = Strip(truePart);
- condvarFalse = Strip(falsePart);
- type = cVarParser::condition;
- return true;
- }
- }
- LogFile.eSysLog("error parsing '%s'", input.c_str());
- condEqLeft = condEqRight = "";
- return false;
+ int condEndPos = input.find("?");
+ string cond(input.begin(), input.begin() + condEndPos);
+ int condNeqPos = cond.find("!=");
+ int condEqPos = cond.find("==");
+
+ if (condEqPos == -1 && condNeqPos == -1) {
+ cond += "!=";
+ condNeqPos = cond.find("!=");
+ }
+
+ if (condEqPos >= 0 || condNeqPos >= 0) {
+ if (!ParseEquality(cond)) {
+ LogFile.eSysLog("error parsing '%s'", input.c_str());
+ return false;
+ }
+ condOp = (condEqPos >= 0) ? condEq : condNeq;
+ } else {
+ LogFile.eSysLog("error parsing '%s'", input.c_str());
+ return false;
+ }
+
+ string truefalse(input.begin() + condEndPos + 1, input.end());
+ int elsePos = truefalse.find(":");
+ if (elsePos >= 0) {
+ string truePart(truefalse.begin(), truefalse.begin() + elsePos);
+ string falsePart(truefalse.begin() + elsePos + 1, truefalse.end());
+ if (ParseVar(truePart) && ParseVar(falsePart)) {
+ condvarTrue = Strip(truePart);
+ condvarFalse = Strip(falsePart);
+ type = cVarParser::condition;
+ return true;
+ }
+ }
+ LogFile.eSysLog("error parsing '%s'", input.c_str());
+ condEqLeft = condEqRight = "";
+ return false;
}
bool cVarParser::ParseEquality(const string& input)
{
- int condEqPos = input.find("==");
- int condNeqPos = input.find("!=");
- int condOpPos = -1;
- if (condEqPos >= 0) condOpPos = condEqPos;
- if (condNeqPos >= 0) condOpPos = condNeqPos;
- if (condOpPos == -1) return false;
- string left(input.begin(), input.begin() + condOpPos);
- string right(input.begin() + condOpPos + 2, input.end());
- if (ParseExp(left) && ParseExp(right))
- {
- condEqLeft = Strip(left);
- condEqRight = Strip(right);
- return true;
- }
- return false;
+ int condEqPos = input.find("==");
+ int condNeqPos = input.find("!=");
+ int condOpPos = -1;
+ if (condEqPos >= 0) condOpPos = condEqPos;
+ if (condNeqPos >= 0) condOpPos = condNeqPos;
+ if (condOpPos == -1) return false;
+ string left(input.begin(), input.begin() + condOpPos);
+ string right(input.begin() + condOpPos + 2, input.end());
+ if (ParseExp(left) && ParseExp(right)) {
+ condEqLeft = Strip(left);
+ condEqRight = Strip(right);
+ return true;
+ }
+ return false;
}
bool cVarParser::ParseVar(const string& input)
{
- string str = Strip(input);
- if (str.size() > 2 && str[0] == '%' && str[str.size()-1] == '%')
- return true;
- return false;
+ string str = Strip(input);
+ if (str.size() > 2 && str[0] == '%' && str[str.size() - 1] == '%')
+ return true;
+ return false;
}
bool cVarParser::IsCondExpr()
{
- return type == cVarParser::condition;
+ return type == cVarParser::condition;
}
bool cVarParser::IsShellCmd()
{
- return type == cVarParser::shellcmd;
+ return type == cVarParser::shellcmd;
}
bool cVarParser::IsConnectCmd()
{
- return type == cVarParser::connectcmd;
+ return type == cVarParser::connectcmd;
}
bool cVarParser::IsLengthCmd()
{
- return type == cVarParser::lengthcmd;
+ return type == cVarParser::lengthcmd;
}
diff --git a/varparser.h b/varparser.h
index 6543e52..64c7372 100644
--- a/varparser.h
+++ b/varparser.h
@@ -32,24 +32,22 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
using std::string;
using std::vector;
-typedef enum
-{
+typedef enum {
condEq = 0,
condNeq
} condOperator;
class cVarParser
{
- typedef enum
- {
- composed=0,
- condition,
- shellcmd,
- connectcmd,
- lengthcmd
- } exprType;
+ typedef enum {
+ composed = 0,
+ condition,
+ shellcmd,
+ connectcmd,
+ lengthcmd
+ } exprType;
- public:
+public:
string varName;
string condEqLeft;
string condEqRight;
@@ -65,14 +63,16 @@ class cVarParser
int connectPort;
exprType type;
- cVarParser() : cmd(NULL), connectPort(-1), type(composed) { condOp=condEq; }
+ cVarParser() : cmd(NULL), connectPort(-1), type(composed) {
+ condOp = condEq;
+ }
bool Parse(const string& input);
bool ParseExp(const string& input);
bool IsCondExpr();
bool IsShellCmd();
bool IsConnectCmd();
bool IsLengthCmd();
- private:
+private:
bool ParseAssign(const string& input);
bool ParseShellCmd(const string& input);
bool ParseConnectCmd(const string& input);