From c4d82eac3686c2f330b1998604f1e1bf327b9033 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Fri, 31 Oct 2014 22:07:33 +0200 Subject: [PATCH] Added support for blacklisted sources. --- HISTORY | 1 + README | 5 +- common.h | 1 + config.c | 21 ++++++++ config.h | 4 ++ device.c | 10 +++- po/ca_ES.po | 22 +++++++-- po/de_DE.po | 22 +++++++-- po/es_ES.po | 22 +++++++-- po/fi_FI.po | 25 ++++++++-- satip.c | 26 ++++++++++ sectionfilter.c | 10 ++-- setup.c | 124 +++++++++++++++++++++++++++++++++++++++++++----- setup.h | 3 ++ 14 files changed, 256 insertions(+), 40 deletions(-) diff --git a/HISTORY b/HISTORY index 7ae3442..de8f455 100644 --- a/HISTORY +++ b/HISTORY @@ -68,3 +68,4 @@ VDR Plugin 'satip' Revision History 2014-xx-xx: Version 0.3.4 - Fixed the cable only device detection. +- Added support for blacklisted sources. diff --git a/README b/README index 7fae2eb..0f2d9c6 100644 --- a/README +++ b/README @@ -71,10 +71,13 @@ Setup menu: - Enable EPG scanning = yes If you want exclude all SAT>IP devices from VDR's EIT background scanning, set this option to "no". +- Disabled sources = none If your SAT>IP servers don't have certain + satellite positions available you can + disable them via this option. - Disabled filters = none Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized etc. This option - allows creation of blacklists of ill-behaving + allows creation of blacklists of ill-behaving filters. If this option is set to a non-zero value, the menu page will contain that many "Disable filter" options which allow you diff --git a/common.h b/common.h index 3fec88e..6bbbab4 100644 --- a/common.h +++ b/common.h @@ -36,6 +36,7 @@ #define SATIP_STATS_ACTIVE_PIDS_COUNT 10 #define SATIP_STATS_ACTIVE_FILTERS_COUNT 10 +#define MAX_DISABLED_SOURCES_COUNT 5 #define SECTION_FILTER_TABLE_SIZE 5 #define SATIP_CURL_EASY_GETINFO(X, Y, Z) \ diff --git a/config.c b/config.c index 94b64c0..4825a81 100644 --- a/config.c +++ b/config.c @@ -15,11 +15,32 @@ cSatipConfig::cSatipConfig(void) eitScanM(1), useBytesM(1) { + for (unsigned int i = 0; i < ARRAY_SIZE(disabledSourcesM); ++i) + disabledSourcesM[i] = cSource::stNone; for (unsigned int i = 0; i < ARRAY_SIZE(disabledFiltersM); ++i) disabledFiltersM[i] = -1; memset(configDirectoryM, 0, sizeof(configDirectoryM)); } +unsigned int cSatipConfig::GetDisabledSourcesCount(void) const +{ + unsigned int n = 0; + while ((n < ARRAY_SIZE(disabledSourcesM) && (disabledSourcesM[n] != cSource::stNone))) + n++; + return n; +} + +int cSatipConfig::GetDisabledSources(unsigned int indexP) const +{ + return (indexP < ARRAY_SIZE(disabledSourcesM)) ? disabledSourcesM[indexP] : cSource::stNone; +} + +void cSatipConfig::SetDisabledSources(unsigned int indexP, int sourceP) +{ + if (indexP < ARRAY_SIZE(disabledSourcesM)) + disabledSourcesM[indexP] = sourceP; +} + unsigned int cSatipConfig::GetDisabledFiltersCount(void) const { unsigned int n = 0; diff --git a/config.h b/config.h index b270b4c..9555480 100644 --- a/config.h +++ b/config.h @@ -17,6 +17,7 @@ private: unsigned int operatingModeM; unsigned int eitScanM; unsigned int useBytesM; + int disabledSourcesM[MAX_DISABLED_SOURCES_COUNT]; int disabledFiltersM[SECTION_FILTER_TABLE_SIZE]; char configDirectoryM[PATH_MAX]; @@ -38,6 +39,8 @@ public: unsigned int GetEITScan(void) const { return eitScanM; } unsigned int GetUseBytes(void) const { return useBytesM; } const char *GetConfigDirectory(void) const { return configDirectoryM; } + unsigned int GetDisabledSourcesCount(void) const; + int GetDisabledSources(unsigned int indexP) const; unsigned int GetDisabledFiltersCount(void) const; int GetDisabledFilters(unsigned int indexP) const; @@ -45,6 +48,7 @@ public: void SetEITScan(unsigned int onOffP) { eitScanM = onOffP; } void SetUseBytes(unsigned int onOffP) { useBytesM = onOffP; } void SetConfigDirectory(const char *directoryP); + void SetDisabledSources(unsigned int indexP, int sourceP); void SetDisabledFilters(unsigned int indexP, int numberP); }; diff --git a/device.c b/device.c index 5845ba5..d774929 100644 --- a/device.c +++ b/device.c @@ -185,7 +185,15 @@ int cSatipDevice::SignalQuality(void) const bool cSatipDevice::ProvidesSource(int sourceP) const { //debug("cSatipDevice::%s(%u)", __FUNCTION__, deviceIndexM); - return (!SatipConfig.IsOperatingModeOff() && !!cSatipDiscover::GetInstance()->GetServer(sourceP)); + if (!SatipConfig.IsOperatingModeOff() && !!cSatipDiscover::GetInstance()->GetServer(sourceP)) { + int numDisabledSourcesM = SatipConfig.GetDisabledSourcesCount(); + for (int i = 0; i < numDisabledSourcesM; ++i) { + if (sourceP == SatipConfig.GetDisabledSources(i)) + return false; + } + return true; + } + return false; } bool cSatipDevice::ProvidesTransponder(const cChannel *channelP) const diff --git a/po/ca_ES.po b/po/ca_ES.po index 1d357ee..117eae0 100644 --- a/po/ca_ES.po +++ b/po/ca_ES.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-satip 0.3.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-18 05:18+0200\n" -"PO-Revision-Date: 2014-05-18 05:18+0200\n" +"POT-Creation-Date: 2014-10-31 10:31+0200\n" +"PO-Revision-Date: 2014-10-31 10:31+0200\n" "Last-Translator: Gabriel Bonich \n" "Language-Team: Catalan \n" "Language: ca\n" @@ -109,16 +109,28 @@ msgstr "" "\n" "Aquesta configuració desactiva la funcionalitat d'escaneig EIT automàtica per a tots els dispositius SAT>IP." -msgid "Disabled filters" -msgstr "Desactiva filtres" +msgid "Disabled sources" +msgstr "" msgid "none" msgstr "no" +msgid "" +"Define number of sources to be disabled.\n" +"\n" +"SAT>IP servers might not have all satellite positions available and such sources can be blacklisted here." +msgstr "" + +msgid "Define a source to be blacklisted." +msgstr "" + +msgid "Disabled filters" +msgstr "Desactiva filtres" + msgid "" "Define number of section filters to be disabled.\n" "\n" -"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process." +"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By blacklisting the filters here, useful section data can be left intact for VDR to process." msgstr "" "Defineix el numero de filtres de secció que seran deshabilitats.\n" "\n" diff --git a/po/de_DE.po b/po/de_DE.po index 4f1b7ac..c19f215 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-satip 0.3.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-18 05:18+0200\n" -"PO-Revision-Date: 2014-05-18 05:18+0200\n" +"POT-Creation-Date: 2014-10-31 10:31+0200\n" +"PO-Revision-Date: 2014-10-31 10:31+0200\n" "Last-Translator: Frank Neumann \n" "Language-Team: German \n" "Language: de\n" @@ -109,16 +109,28 @@ msgstr "" "\n" "Diese Einstellung schaltet die automatische EIT Aktualisierung für alle SAT>IP Geräte." -msgid "Disabled filters" -msgstr "Deaktivierte Filter" +msgid "Disabled sources" +msgstr "" msgid "none" msgstr "keine" +msgid "" +"Define number of sources to be disabled.\n" +"\n" +"SAT>IP servers might not have all satellite positions available and such sources can be blacklisted here." +msgstr "" + +msgid "Define a source to be blacklisted." +msgstr "" + +msgid "Disabled filters" +msgstr "Deaktivierte Filter" + msgid "" "Define number of section filters to be disabled.\n" "\n" -"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process." +"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By blacklisting the filters here, useful section data can be left intact for VDR to process." msgstr "" "Bestimme die Anzahl der Abschnittsfilter die deaktiviert werden sollen.\n" "\n" diff --git a/po/es_ES.po b/po/es_ES.po index 6f8e7ac..fbd0fbf 100644 --- a/po/es_ES.po +++ b/po/es_ES.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-satip 0.3.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-18 05:18+0200\n" -"PO-Revision-Date: 2014-05-18 05:18+0200\n" +"POT-Creation-Date: 2014-10-31 10:31+0200\n" +"PO-Revision-Date: 2014-10-31 10:31+0200\n" "Last-Translator: Gabriel Bonich \n" "Language-Team: Spanish \n" "Language: es\n" @@ -109,16 +109,28 @@ msgstr "" "\n" "Esta configuración desactiva la funcionalidad del escaneo EIT automática para todos los Dispositivos SAT>IP." -msgid "Disabled filters" -msgstr "Desactiva filtros" +msgid "Disabled sources" +msgstr "" msgid "none" msgstr "no" +msgid "" +"Define number of sources to be disabled.\n" +"\n" +"SAT>IP servers might not have all satellite positions available and such sources can be blacklisted here." +msgstr "" + +msgid "Define a source to be blacklisted." +msgstr "" + +msgid "Disabled filters" +msgstr "Desactiva filtros" + msgid "" "Define number of section filters to be disabled.\n" "\n" -"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process." +"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By blacklisting the filters here, useful section data can be left intact for VDR to process." msgstr "" "Define el numero de filtros de sección que seran deshabilitados.\n" "\n" diff --git a/po/fi_FI.po b/po/fi_FI.po index b34554e..29779b2 100644 --- a/po/fi_FI.po +++ b/po/fi_FI.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-satip 0.3.4\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-18 05:18+0200\n" -"PO-Revision-Date: 2014-05-18 05:18+0200\n" +"POT-Creation-Date: 2014-10-31 10:31+0200\n" +"PO-Revision-Date: 2014-10-31 10:31+0200\n" "Last-Translator: Rolf Ahrenberg\n" "Language-Team: Finnish \n" "Language: fi\n" @@ -108,16 +108,31 @@ msgstr "" "\n" "Tällä asetuksella saadaan otettua automaattinen EIT-datan päivitys pois päältä kaikilta SAT>IP-laitteilta." -msgid "Disabled filters" -msgstr "Käytöstä poistetut suodattimet" +msgid "Disabled sources" +msgstr "Käytöstä poistetut lähteet" msgid "none" msgstr "tyhjä" +msgid "" +"Define number of sources to be disabled.\n" +"\n" +"SAT>IP servers might not have all satellite positions available and such sources can be blacklisted here." +msgstr "" +"Määrittele käytöstä poistettavien lähteiden lukumäärä.\n" +"\n" +"SAT>IP-palvelimilla ei välttämättä ole kaikkia ohjelmalähteitä tarjolla." + +msgid "Define a source to be blacklisted." +msgstr "Määrittele käytöstä" + +msgid "Disabled filters" +msgstr "Käytöstä poistetut suodattimet" + msgid "" "Define number of section filters to be disabled.\n" "\n" -"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process." +"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By blacklisting the filters here, useful section data can be left intact for VDR to process." msgstr "" "Määrittele käytöstä poistettavien suodattimien lukumäärä sektioille.\n" "\n" diff --git a/satip.c b/satip.c index 6a484ec..9a7122a 100644 --- a/satip.c +++ b/satip.c @@ -32,6 +32,7 @@ class cPluginSatip : public cPlugin { private: unsigned int deviceCountM; cSatipDiscover *discoverM; + int ParseSources(const char *valueP, int *sourcesP); int ParseFilters(const char *valueP, int *filtersP); public: cPluginSatip(void); @@ -177,6 +178,23 @@ cMenuSetupPage *cPluginSatip::SetupMenu(void) return new cSatipPluginSetup(); } +int cPluginSatip::ParseSources(const char *valueP, int *sourcesP) +{ + debug("cPluginSatip::%s(%s)", __FUNCTION__, valueP); + int n = 0; + char *s, *p = (char *)valueP; + char *r = strtok_r(p, " ", &s); + while (r) { + r = skipspace(r); + debug("cPluginSatip::%s(): sources[%d]=%s", __FUNCTION__, n, r); + if (n < MAX_DISABLED_SOURCES_COUNT) { + sourcesP[n++] = cSource::FromString(r); + } + r = strtok_r(NULL, " \n", &s); + } + return n; +} + int cPluginSatip::ParseFilters(const char *valueP, int *filtersP) { debug("cPluginSatip::%s(%s)", __FUNCTION__, valueP); @@ -202,6 +220,14 @@ bool cPluginSatip::SetupParse(const char *nameP, const char *valueP) SatipConfig.SetOperatingMode(atoi(valueP)); else if (!strcasecmp(nameP, "EnableEITScan")) SatipConfig.SetEITScan(atoi(valueP)); + else if (!strcasecmp(nameP, "DisabledSources")) { + int DisabledSources[MAX_DISABLED_SOURCES_COUNT]; + for (unsigned int i = 0; i < ARRAY_SIZE(DisabledSources); ++i) + DisabledSources[i] = cSource::stNone; + unsigned int DisabledSourcesCount = ParseSources(valueP, DisabledSources); + for (unsigned int i = 0; i < DisabledSourcesCount; ++i) + SatipConfig.SetDisabledSources(i, DisabledSources[i]); + } else if (!strcasecmp(nameP, "DisabledFilters")) { int DisabledFilters[SECTION_FILTER_TABLE_SIZE]; for (unsigned int i = 0; i < ARRAY_SIZE(DisabledFilters); ++i) diff --git a/sectionfilter.c b/sectionfilter.c index 395b7a9..e24a48a 100644 --- a/sectionfilter.c +++ b/sectionfilter.c @@ -37,10 +37,10 @@ cSatipSectionFilter::cSatipSectionFilter(int deviceIndexP, uint16_t pidP, uint8_ for (i = 0; i < eDmxMaxFilterSize; ++i) filterValueM[i] ^= 0xFF; - uint8_t mask, mode, doneq = 0; + uint8_t doneq = 0; for (i = 0; i < eDmxMaxFilterSize; ++i) { - mode = filterModeM[i]; - mask = filterMaskM[i]; + uint8_t mode = filterModeM[i]; + uint8_t mask = filterMaskM[i]; maskAndModeM[i] = (uint8_t)(mask & mode); maskAndNotModeM[i] = (uint8_t)(mask & ~mode); doneq |= maskAndNotModeM[i]; @@ -117,7 +117,7 @@ inline int cSatipSectionFilter::Feed(void) int cSatipSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP) { - uint16_t limit, seclen, n; + uint16_t limit, n; if (tsFeedpM >= eDmxMaxSectionFeedSize) return 0; @@ -139,7 +139,7 @@ int cSatipSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP) secBufM = secBufBaseM + secBufpM; for (n = 0; secBufpM + 2 < limit; ++n) { - seclen = GetLength(secBufM); + uint16_t seclen = GetLength(secBufM); if ((seclen <= 0) || (seclen > eDmxMaxSectionSize) || ((seclen + secBufpM) > limit)) return 0; secLenM = seclen; diff --git a/setup.c b/setup.c index 5cf73c2..0cabe68 100644 --- a/setup.c +++ b/setup.c @@ -14,6 +14,72 @@ #include "discover.h" #include "setup.h" +// --- cSatipEditSrcItem ------------------------------------------------------ +// This class is a 99% copy of cMenuEditSrcItem() taken from VDR's menu.c + +class cSatipEditSrcItem : public cMenuEditIntItem { +private: + const cSource *source; +protected: + virtual void Set(void); +public: + cSatipEditSrcItem(const char *Name, int *Value); + eOSState ProcessKey(eKeys Key); + }; + +cSatipEditSrcItem::cSatipEditSrcItem(const char *Name, int *Value) +:cMenuEditIntItem(Name, Value, 0) +{ + source = Sources.Get(*Value); + if (!source) + source = Sources.First(); + Set(); +} + +void cSatipEditSrcItem::Set(void) +{ + if (source) + SetValue(cString::sprintf("%s - %s", *cSource::ToString(source->Code()), source->Description())); + else + cMenuEditIntItem::Set(); +} + +eOSState cSatipEditSrcItem::ProcessKey(eKeys Key) +{ + eOSState state = cMenuEditItem::ProcessKey(Key); + + if (state == osUnknown) { + bool IsRepeat = Key & k_Repeat; + Key = NORMALKEY(Key); + if (Key == kLeft) { // TODO might want to increase the delta if repeated quickly? + if (source) { + if (source->Prev()) + source = (cSource *)source->Prev(); + else if (!IsRepeat) + source = Sources.Last(); + *value = source->Code(); + } + } + else if (Key == kRight) { + if (source) { + if (source->Next()) + source = (cSource *)source->Next(); + else if (!IsRepeat) + source = Sources.First(); + } + else + source = Sources.First(); + if (source) + *value = source->Code(); + } + else + return state; // we don't call cMenuEditIntItem::ProcessKey(Key) here since we don't accept numerical input + Set(); + state = osContinue; + } + return state; +} + // --- cSatipServerInfo ------------------------------------------------------- class cSatipServerInfo : public cOsdMenu @@ -198,6 +264,7 @@ cSatipPluginSetup::cSatipPluginSetup() : deviceCountM(0), operatingModeM(SatipConfig.GetOperatingMode()), eitScanM(SatipConfig.GetEITScan()), + numDisabledSourcesM(SatipConfig.GetDisabledSourcesCount()), numDisabledFiltersM(SatipConfig.GetDisabledFiltersCount()) { debug("cSatipPluginSetup::%s()", __FUNCTION__); @@ -205,6 +272,10 @@ cSatipPluginSetup::cSatipPluginSetup() operatingModeTextsM[cSatipConfig::eOperatingModeLow] = tr("low"); operatingModeTextsM[cSatipConfig::eOperatingModeNormal] = tr("normal"); operatingModeTextsM[cSatipConfig::eOperatingModeHigh] = tr("high"); + if (numDisabledSourcesM > MAX_DISABLED_SOURCES_COUNT) + numDisabledSourcesM = MAX_DISABLED_SOURCES_COUNT; + for (int i = 0; i < MAX_DISABLED_SOURCES_COUNT; ++i) + disabledSourcesM[i] = SatipConfig.GetDisabledSources(i); if (numDisabledFiltersM > SECTION_FILTER_TABLE_SIZE) numDisabledFiltersM = SECTION_FILTER_TABLE_SIZE; for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) { @@ -230,8 +301,16 @@ void cSatipPluginSetup::Setup(void) Add(new cMenuEditBoolItem(tr("Enable EPG scanning"), &eitScanM)); helpM.Append(tr("Define whether the EPG background scanning shall be used.\n\nThis setting disables the automatic EIT scanning functionality for all SAT>IP devices.")); + Add(new cMenuEditIntItem(tr("Disabled sources"), &numDisabledSourcesM, 0, MAX_DISABLED_SOURCES_COUNT, tr("none"))); + helpM.Append(tr("Define number of sources to be disabled.\n\nSAT>IP servers might not have all satellite positions available and such sources can be blacklisted here.")); + + for (int i = 0; i < numDisabledSourcesM; ++i) { + Add(new cSatipEditSrcItem(*cString::sprintf(" %s %d", trVDR("Source"), i + 1), &disabledSourcesM[i])); + helpM.Append(tr("Define a source to be blacklisted.")); + } + Add(new cMenuEditIntItem(tr("Disabled filters"), &numDisabledFiltersM, 0, SECTION_FILTER_TABLE_SIZE, tr("none"))); - helpM.Append(tr("Define number of section filters to be disabled.\n\nCertain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process.")); + helpM.Append(tr("Define number of section filters to be disabled.\n\nCertain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By blacklisting the filters here, useful section data can be left intact for VDR to process.")); for (int i = 0; i < numDisabledFiltersM; ++i) { Add(new cMenuEditStraItem(*cString::sprintf(" %s %d", tr("Filter"), i + 1), &disabledFilterIndexesM[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNamesM)); @@ -286,6 +365,7 @@ eOSState cSatipPluginSetup::ProcessKey(eKeys keyP) { bool hadSubMenu = HasSubMenu(); int oldOperatingMode = operatingModeM; + int oldNumDisabledSources = numDisabledSourcesM; int oldNumDisabledFilters = numDisabledFiltersM; eOSState state = cMenuSetupPage::ProcessKey(keyP); @@ -307,7 +387,9 @@ eOSState cSatipPluginSetup::ProcessKey(eKeys keyP) if ((keyP == kNone) && (cSatipDiscover::GetInstance()->GetServers()->Count() != deviceCountM)) Setup(); - if ((keyP != kNone) && ((numDisabledFiltersM != oldNumDisabledFilters) || (operatingModeM != oldOperatingMode))) { + if ((keyP != kNone) && ((numDisabledSourcesM != oldNumDisabledSources) || (numDisabledFiltersM != oldNumDisabledFilters) || (operatingModeM != oldOperatingMode))) { + while ((numDisabledSourcesM < oldNumDisabledSources) && (oldNumDisabledSources > 0)) + disabledSourcesM[--oldNumDisabledSources] = cSource::stNone; while ((numDisabledFiltersM < oldNumDisabledFilters) && (oldNumDisabledFilters > 0)) disabledFilterIndexesM[--oldNumDisabledFilters] = -1; Setup(); @@ -316,23 +398,36 @@ eOSState cSatipPluginSetup::ProcessKey(eKeys keyP) return state; } +void cSatipPluginSetup::StoreSources(const char *nameP, int *sourcesP) +{ + cString buffer = ""; + int n = 0; + for (int i = 0; i < MAX_DISABLED_SOURCES_COUNT; ++i) { + if (sourcesP[i] == cSource::stNone) + break; + if (n++ > 0) + buffer = cString::sprintf("%s %s", *buffer, *cSource::ToString(sourcesP[i])); + else + buffer = cString::sprintf("%s", *cSource::ToString(sourcesP[i])); + } + debug("cSatipPluginSetup::%s(%s, %s)", __FUNCTION__, nameP, *buffer); + SetupStore(nameP, *buffer); +} + void cSatipPluginSetup::StoreFilters(const char *nameP, int *valuesP) { - char buffer[SECTION_FILTER_TABLE_SIZE * 4]; - char *q = buffer; + cString buffer = ""; + int n = 0; for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) { - char s[3]; if (valuesP[i] < 0) break; - if (q > buffer) - *q++ = ' '; - snprintf(s, sizeof(s), "%d", valuesP[i]); - strncpy(q, s, strlen(s)); - q += strlen(s); + if (n++ > 0) + buffer = cString::sprintf("%s %d", *buffer, valuesP[i]); + else + buffer = cString::sprintf("%d", valuesP[i]); } - *q = 0; - debug("cSatipPluginSetup::%s(%s, %s)", __FUNCTION__, nameP, buffer); - SetupStore(nameP, buffer); + debug("cSatipPluginSetup::%s(%s, %s)", __FUNCTION__, nameP, *buffer); + SetupStore(nameP, *buffer); } void cSatipPluginSetup::Store(void) @@ -340,10 +435,13 @@ void cSatipPluginSetup::Store(void) // Store values into setup.conf SetupStore("OperatingMode", operatingModeM); SetupStore("EnableEITScan", eitScanM); + StoreSources("DisabledSources", disabledSourcesM); StoreFilters("DisabledFilters", disabledFilterIndexesM); // Update global config SatipConfig.SetOperatingMode(operatingModeM); SatipConfig.SetEITScan(eitScanM); + for (int i = 0; i < MAX_DISABLED_SOURCES_COUNT; ++i) + SatipConfig.SetDisabledSources(i, disabledSourcesM[i]); for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) SatipConfig.SetDisabledFilters(i, disabledFilterIndexesM[i]); } diff --git a/setup.h b/setup.h index 7d2b60a..8cf1792 100644 --- a/setup.h +++ b/setup.h @@ -19,6 +19,8 @@ private: int operatingModeM; const char *operatingModeTextsM[cSatipConfig::eOperatingModeCount]; int eitScanM; + int numDisabledSourcesM; + int disabledSourcesM[MAX_DISABLED_SOURCES_COUNT]; int numDisabledFiltersM; int disabledFilterIndexesM[SECTION_FILTER_TABLE_SIZE]; const char *disabledFilterNamesM[SECTION_FILTER_TABLE_SIZE]; @@ -28,6 +30,7 @@ private: eOSState DeviceInfo(void); eOSState ShowInfo(void); void Setup(void); + void StoreSources(const char *nameP, int *sourcesP); void StoreFilters(const char *nameP, int *valuesP); protected: