diff --git a/pages/ibox.ecpp b/pages/ibox.ecpp index d804995b..f7b57e34 100644 --- a/pages/ibox.ecpp +++ b/pages/ibox.ecpp @@ -63,10 +63,18 @@ TimerConflictNotifier timerNotifier(); cChannel* Channel = (cChannel *)Channels->GetByNumber(cDevice::CurrentChannel()); cChannel* tmp = (cChannel *)Channels->GetByNumber(Channels->GetPrevNormal(cDevice::CurrentChannel()), -SKIP_GAP); +#if VDRVERSNUM >= 20606 + if (tmp) +#else if (tmp && cDevice::PrimaryDevice() && cDevice::PrimaryDevice()->HasDecoder() ) +#endif prev_chan = tmp->GetChannelID(); tmp = (cChannel *)Channels->GetByNumber(Channels->GetNextNormal(cDevice::CurrentChannel()), SKIP_GAP); +#if VDRVERSNUM >= 20606 + if (tmp) +#else if (tmp && cDevice::PrimaryDevice() && cDevice::PrimaryDevice()->HasDecoder() ) +#endif next_chan = tmp->GetChannelID(); const std::string chanName(Channel->Name()); diff --git a/recman.cpp b/recman.cpp index fe51b1bf..32f3c536 100644 --- a/recman.cpp +++ b/recman.cpp @@ -428,28 +428,6 @@ template void StringAppendFrameParams>(cToSvConcat<255> &s, con return first->scraperReleaseDate() < second->scraperReleaseDate(); } -/* - int RecordingsItemPtrCompare::compareLC(const char *first, const char *second, int *numEqualChars) { -// if numEqualChars != NULL: Add the number of equal characters to *numEqualChars - bool fe = !first || !first[0]; // is first string empty string? - bool se = !second || !second[0]; // is second string empty string? - if (fe && se) return 0; - if (se) return 1; - if (fe) return -1; -// compare strings case-insensitive - for(; *first && *second; ) { - wint_t flc = std::tolower(getNextUtfCodepoint(first), g_locale); - wint_t slc = std::tolower(getNextUtfCodepoint(second), g_locale); - if ( flc < slc ) return -1; - if ( flc > slc ) return 1; - if (numEqualChars) (*numEqualChars)++; - } - if (*second ) return -1; - if (*first ) return 1; - return 0; - } -*/ - tCompRec RecordingsItemPtrCompare::getComp(eSortOrder sortOrder) { switch (sortOrder) { case eSortOrder::name: return &RecordingsItemPtrCompare::ByAscendingNameDescSort; diff --git a/recman.h b/recman.h index ad0fb081..c2a97217 100644 --- a/recman.h +++ b/recman.h @@ -165,7 +165,6 @@ template static bool ByAscendingNameSort(const RecordingsItemDirPtr & first, const RecordingsItemDirPtr & second); static bool BySeason(const RecordingsItemDirPtr & first, const RecordingsItemDirPtr & second); // helpers -// static int compareLC(const char *first, const char *second, int *numEqualChars = NULL); // as std::compare, but compare lower case static int FindBestMatch(RecordingsItemRecPtr &BestMatch, const std::vector::const_iterator & First, const std::vector::const_iterator & Last, const RecordingsItemRecPtr & EPG_Entry); static tCompRec getComp(eSortOrder sortOrder); diff --git a/stringhelpers.h b/stringhelpers.h index 6d4ce414..973bb2fa 100644 --- a/stringhelpers.h +++ b/stringhelpers.h @@ -113,6 +113,7 @@ class cSv: public std::string_view { public: utf8_iterator utf8_begin() const; utf8_iterator utf8_end() const; + int compareLowerCase(cSv other, const std::locale &loc); }; // iterator for utf8 @@ -180,6 +181,21 @@ class utf8_iterator { inline utf8_iterator cSv::utf8_begin() const { return utf8_iterator(*this, 0); } inline utf8_iterator cSv::utf8_end() const { return utf8_iterator(*this, length() ); } +inline int cSv::compareLowerCase(cSv other, const std::locale &loc) { +// compare strings case-insensitive + utf8_iterator ls = utf8_begin(); + utf8_iterator rs = other.utf8_begin(); + for (; ls != utf8_end() && rs != other.utf8_end(); ++ls, ++rs) { + wint_t llc = std::tolower(*ls, loc); + wint_t rlc = std::tolower(*rs, loc); + if ( llc < rlc ) return -1; + if ( llc > rlc ) return 1; + } + if (rs != other.utf8_end() ) return -1; + if (ls != utf8_end() ) return 1; + return 0; +} + // ========================================================= // cStr: similar to cSv, but support c_str() diff --git a/tasks.cpp b/tasks.cpp index 1a1781a2..d2475891 100644 --- a/tasks.cpp +++ b/tasks.cpp @@ -33,23 +33,14 @@ StickyTask::~StickyTask() void SwitchChannelTask::Action() { -#if VDRVERSNUM >= 20301 LOCK_CHANNELS_READ; cChannel* channel = (cChannel *)Channels->GetByChannelID( m_channel ); -#else - ReadLock lock( Channels ); - cChannel* channel = Channels.GetByChannelID( m_channel ); -#endif if ( channel == 0 ) { SetError( tr("Couldn't find channel or no channels available.") ); return; } -#if VDRVERSNUM >= 20301 if ( !Channels->SwitchTo( channel->Number() ) ) -#else - if ( !Channels.SwitchTo( channel->Number() ) ) -#endif SetError( tr("Couldn't switch to channel.") ); }