diff options
author | Christian Wieninger <cwieninger@gmx.de> | 2012-01-08 20:39:07 +0100 |
---|---|---|
committer | Christian Wieninger <cwieninger@gmx.de> | 2012-01-08 20:39:07 +0100 |
commit | 50828c595b4967074a9e0e3cef8cef1b64c9d2e1 (patch) | |
tree | 969e6674a88b9bb835192107cad593154e6e7a06 | |
parent | eedb728f5e2f48607a739d15d3ba1053728684ab (diff) | |
download | vdr-plugin-epgsearch-50828c595b4967074a9e0e3cef8cef1b64c9d2e1.tar.gz vdr-plugin-epgsearch-50828c595b4967074a9e0e3cef8cef1b64c9d2e1.tar.bz2 |
sort search timers by timer priority and search term
-rw-r--r-- | HISTORY | 2 | ||||
-rw-r--r-- | HISTORY.DE | 2 | ||||
-rw-r--r-- | doc-src/en/epgsearch.4.txt | 7 | ||||
-rw-r--r-- | epgsearchext.c | 19 | ||||
-rw-r--r-- | epgsearchext.h | 1 | ||||
-rw-r--r-- | epgsearchtools.c | 10 | ||||
-rw-r--r-- | epgsearchtools.h | 1 | ||||
-rw-r--r-- | searchtimer_thread.c | 1 |
8 files changed, 40 insertions, 3 deletions
@@ -3,6 +3,8 @@ VDR Plugin 'epgsearch' Revision History 2011-xx-xx; Version 1.0.1 new: +- search timers are now processed by their descending timer priority. Search timers with the same priority + are sorted by their search term. Thanks to Anonym for providing a patch - new bugtracker at http://projects.vdr-developer.org/projects/plg-epgsearch - thanks to Tobias Grimm - dropped old code for vdr < 1.6.0, thanks to Ville Skyttä for whole pile of patches - updated MainMenuHooks patch to 1.0.1 @@ -3,6 +3,8 @@ VDR Plugin 'epgsearch' Revision History 2011-xx-xx: Version 1.0.1 neu: +- Suchtimer werden jetzt anhand absteigender Timer-Priorität abgearbeitet. Bei + gleicher Priorität wird nach dem Suchbegriff sortiert. Danke an Anonym für den Patch. - Neuer Bugtracker unter http://projects.vdr-developer.org/projects/plg-epgsearch - Danke an Tobias Grimm - alten Code für vdr < 1.6.0 entfernt, Danke an Ville Skyttä für einen ganzen Haufen Patches - MainMenuHooks-Patch auf 1.0.1 aktualisiert diff --git a/doc-src/en/epgsearch.4.txt b/doc-src/en/epgsearch.4.txt index d588d94..72628be 100644 --- a/doc-src/en/epgsearch.4.txt +++ b/doc-src/en/epgsearch.4.txt @@ -207,9 +207,10 @@ time, duration, week day) are checked. =head1 4. How do Search Timers work? -With each update, the plugin searches for new matches of your search -timers. If a new match is found then a new timer is created. For -serial recordings, the subtitle is appended to the recording +With each update, the plugin first sorts the search timers by timer +priority (descending) and search term and then searches for new matches +of your search timers. If a new match is found then a new timer is created. +For serial recordings, the subtitle is appended to the recording directory. Many providers deliver the subtitle just 1-2 days before the event. The plugin uses then a date/time string for the subtitle, but replaces this one later if the subtitle is present. diff --git a/epgsearchext.c b/epgsearchext.c index 8f71241..ba58b3b 100644 --- a/epgsearchext.c +++ b/epgsearchext.c @@ -1663,6 +1663,25 @@ bool cSearchExts::CheckForAutoDelete(cSearchExt* SearchExt) 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]); + } +} + cSearchResult::cSearchResult(const cEvent* Event, int searchID) : event(Event), blacklist(NULL), needsTimer(true) { search = SearchExts.GetSearchFromID(searchID); diff --git a/epgsearchext.h b/epgsearchext.h index 7303d66..cfdd131 100644 --- a/epgsearchext.h +++ b/epgsearchext.h @@ -234,6 +234,7 @@ public: bool Exists(const cSearchExt* SearchExt); cSearchExts* Clone(); bool CheckForAutoDelete(cSearchExt* SearchExt); + void SortBy(int(*compar)(const void *, const void *)); }; extern cSearchExts SearchExts; diff --git a/epgsearchtools.c b/epgsearchtools.c index c2cfb1b..e1b7fd7 100644 --- a/epgsearchtools.c +++ b/epgsearchtools.c @@ -76,6 +76,16 @@ int CompareEventChannel(const void *p1, const void *p2) 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); +} + char* IndentMenuItem(const char* szString, int indentions) { char* szIndented = NULL; diff --git a/epgsearchtools.h b/epgsearchtools.h index 1220cda..2ad1d35 100644 --- a/epgsearchtools.h +++ b/epgsearchtools.h @@ -151,6 +151,7 @@ char* GetRawDescription(const char* descr); 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); int ChannelNrFromEvent(const cEvent* pEvent); void DelTimer(int index); diff --git a/searchtimer_thread.c b/searchtimer_thread.c index cd73cae..af67988 100644 --- a/searchtimer_thread.c +++ b/searchtimer_thread.c @@ -241,6 +241,7 @@ void cSearchTimerThread::Action(void) // 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(); |