diff options
-rw-r--r-- | HISTORY | 5 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | config.c | 32 | ||||
-rw-r--r-- | config.h | 25 | ||||
-rw-r--r-- | duplicates.c | 9 | ||||
-rw-r--r-- | menu.c | 108 | ||||
-rw-r--r-- | menu.h | 18 | ||||
-rw-r--r-- | po/de_DE.po | 4 | ||||
-rw-r--r-- | po/fi_FI.po | 7 | ||||
-rw-r--r-- | po/it_IT.po | 4 |
11 files changed, 195 insertions, 24 deletions
@@ -1,6 +1,11 @@ VDR Plugin 'duplicates' Revision History ---------------------------------------- +2011-12-20: Version 0.0.4 + +- Added configuration option for title comparison. +- Added play button, thanks to Matthias Feistel. + 2011-12-12: Version 0.0.3 - Improved comparison algorithm. @@ -51,7 +51,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): -OBJS = $(PLUGIN).o menu.o +OBJS = $(PLUGIN).o menu.o config.o ### The main target: @@ -24,9 +24,8 @@ Recordings without a description or a short description are not included in the comparison and are shown at the botton of the duplicate recordings list. -Recorings are not considered duplicate if shorter title in not -included in the other title. '@' and '%' characters are removed -in front of the title before the comparison. +Recorings are not considered duplicate if title comparison is +active and shorter title in not included in the other title. The short description and the description are concatenated to a string. Spaces and '|' characters are removed from the string. diff --git a/config.c b/config.c new file mode 100644 index 0000000..5818ebf --- /dev/null +++ b/config.c @@ -0,0 +1,32 @@ +/* + * config.c: A plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + * $Id$ + */ + +#include <stdlib.h> +#include <strings.h> +#include <vdr/plugin.h> +#include "config.h" + +cDuplicatesConfig::cDuplicatesConfig() { + title = 1; +} + +cDuplicatesConfig::~cDuplicatesConfig() { } + + +bool cDuplicatesConfig::SetupParse(const char *Name, const char *Value) { + if (!strcasecmp(Name, "title")) title = atoi(Value); + else + return false; + return true; +} + +void cDuplicatesConfig::Store(void) { + cPluginManager::GetPlugin(PLUGIN_NAME_I18N)->SetupStore("title", title); +} + +cDuplicatesConfig dc; diff --git a/config.h b/config.h new file mode 100644 index 0000000..810721e --- /dev/null +++ b/config.h @@ -0,0 +1,25 @@ +/* + * config.h: A plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + * $Id$ + */ + +#ifndef _DUPLICATES_CONFIG_H +#define _DUPLICATES_CONFIG_H + +class cDuplicatesConfig { + public: + // variables + int title; + // member functions + cDuplicatesConfig(); + ~cDuplicatesConfig(); + bool SetupParse(const char *Name, const char *Value); + void Store(void); +}; + +extern cDuplicatesConfig dc; + +#endif diff --git a/duplicates.c b/duplicates.c index 6f58b23..7294506 100644 --- a/duplicates.c +++ b/duplicates.c @@ -8,9 +8,10 @@ #include <vdr/plugin.h> +#include "config.h" #include "menu.h" -static const char *VERSION = "0.0.3"; +static const char *VERSION = "0.0.4"; static const char *DESCRIPTION = trNOOP("Shows duplicate recordings"); static const char *MAINMENUENTRY = trNOOP("Duplicate recordings"); @@ -21,7 +22,7 @@ public: cPluginDuplicates(void); virtual ~cPluginDuplicates(); virtual const char *Version(void) { return VERSION; } - virtual const char *Description(void) { return DESCRIPTION; } + virtual const char *Description(void) { return tr(DESCRIPTION); } virtual const char *CommandLineHelp(void); virtual bool ProcessArgs(int argc, char *argv[]); virtual bool Initialize(void); @@ -113,13 +114,13 @@ cOsdObject *cPluginDuplicates::MainMenuAction(void) cMenuSetupPage *cPluginDuplicates::SetupMenu(void) { // Return a setup menu in case the plugin supports one. - return NULL; + return new cMenuSetupDuplicates; } bool cPluginDuplicates::SetupParse(const char *Name, const char *Value) { // Parse your own setup parameters and store their values. - return false; + return dc.SetupParse(Name, Value);; } bool cPluginDuplicates::Service(const char *Id, void *Data) @@ -14,7 +14,6 @@ #include <vdr/interface.h> #include <string> #include <sstream> -#include <vector> static inline cOsdItem *SeparatorItem(const char *Label) { @@ -23,6 +22,25 @@ static inline cOsdItem *SeparatorItem(const char *Label) return Item; } +// --- cDuplicatesReplayControl ------------------------------------------------------- + +class cDuplicatesReplayControl : public cReplayControl { +public: + virtual eOSState ProcessKey(eKeys Key); + }; + +eOSState cDuplicatesReplayControl::ProcessKey(eKeys Key) +{ + eOSState state = cReplayControl::ProcessKey(Key); + if (state == osRecordings) + { + cControl::Shutdown(); + cRemote::CallPlugin("duplicates"); + return osContinue; + } + return state; +} + // --- cMenuDuplicate -------------------------------------------------------- class cMenuDuplicate : public cOsdMenu { @@ -38,6 +56,7 @@ cMenuDuplicate::cMenuDuplicate(const cRecording *Recording) :cOsdMenu(trVDR("Recording info")) { recording = Recording; + SetHelp(trVDR("Button$Play")); } void cMenuDuplicate::Display(void) @@ -70,6 +89,8 @@ eOSState cMenuDuplicate::ProcessKey(eKeys Key) if (state == osUnknown) { switch (Key) { + case kPlay: + case kRed: cRemote::Put(Key, true); case kOk: return osBack; default: break; } @@ -126,12 +147,8 @@ cDuplicateRecording::cDuplicateRecording(const cRecording *Recording) { recording = Recording; checked = false; - if (recording->Info()->Title()) - { + if (dc.title && recording->Info()->Title()) title = std::string(recording->Info()->Title()); - if (title.length() > 1 && (title[0] == '@' || title[0] == '%')) - title = title.substr(1); - } else title = std::string(); std::stringstream desc; @@ -156,6 +173,7 @@ cDuplicateRecording::cDuplicateRecording(const cRecording *Recording) cDuplicateRecording::~cDuplicateRecording() { + title.clear(); description.clear(); } @@ -170,10 +188,13 @@ bool cDuplicateRecording::IsDuplicate(const cDuplicateRecording *DuplicateRecord return false; size_t found; - found = title.size() > DuplicateRecording->title.size() ? - title.find(DuplicateRecording->title) : DuplicateRecording->title.find(title); - if (found == std::string::npos) - return false; + if (dc.title) + { + found = title.size() > DuplicateRecording->title.size() ? + title.find(DuplicateRecording->title) : DuplicateRecording->title.find(title); + if (found == std::string::npos) + return false; + } found = description.size() > DuplicateRecording->description.size() ? description.find(DuplicateRecording->description) : DuplicateRecording->description.find(description); @@ -218,7 +239,7 @@ void cMenuDuplicates::SetHelpKeys(void) switch (NewHelpKeys) { case 0: SetHelp(NULL); break; case 1: - case 2: SetHelp(NULL, NULL, trVDR("Button$Delete"), NewHelpKeys == 2 ? trVDR("Button$Info") : NULL); + case 2: SetHelp(trVDR("Button$Play"), trVDR("Setup"), trVDR("Button$Delete"), NewHelpKeys == 2 ? trVDR("Button$Info") : NULL); default: ; } helpKeys = NewHelpKeys; @@ -227,9 +248,12 @@ void cMenuDuplicates::SetHelpKeys(void) void cMenuDuplicates::Set(bool Refresh) { + const char *CurrentRecording = NULL; int currentIndex = -1; if (Refresh) currentIndex = Current(); + else + CurrentRecording = cReplayControl::LastReplayed(); cList<cDuplicateRecording> *descriptionless = new cList<cDuplicateRecording>; cList<cDuplicateRecording> *recordings = new cList<cDuplicateRecording>; cThreadLock RecordingsLock(&Recordings); @@ -258,7 +282,11 @@ void cMenuDuplicates::Set(bool Refresh) for (cDuplicateRecording *DuplicateRecording = duplicates->First(); DuplicateRecording; DuplicateRecording = duplicates->Next(DuplicateRecording)) { cMenuDuplicateItem *Item = new cMenuDuplicateItem(DuplicateRecording->Recording()); if (*Item->Text()) + { Add(Item); + if (CurrentRecording && strcmp(CurrentRecording, Item->FileName()) == 0) + SetCurrent(Item); + } else delete Item; } @@ -271,7 +299,11 @@ void cMenuDuplicates::Set(bool Refresh) for (cDuplicateRecording *DescriptionlessRecording = descriptionless->First(); DescriptionlessRecording; DescriptionlessRecording = descriptionless->Next(DescriptionlessRecording)) { cMenuDuplicateItem *Item = new cMenuDuplicateItem(DescriptionlessRecording->Recording()); if (*Item->Text()) + { Add(Item); + if (CurrentRecording && strcmp(CurrentRecording, Item->FileName()) == 0) + SetCurrent(Item); + } else delete Item; } @@ -346,6 +378,32 @@ eOSState cMenuDuplicates::Delete(void) return osContinue; } +eOSState cMenuDuplicates::Play(void) +{ + if (HasSubMenu() || Count() == 0) + return osContinue; + cMenuDuplicateItem *ri = (cMenuDuplicateItem *)Get(Current()); + if (ri) { + cRecording *recording = GetRecording(ri); + if (recording) { + cDuplicatesReplayControl::SetRecording(recording->FileName(), recording->Title()); + cControl::Shutdown(); + cControl::Launch(new cDuplicatesReplayControl); + return osEnd; + } + } + return osContinue; +} + +eOSState cMenuDuplicates::Setup(void) +{ + if (HasSubMenu()) + return osContinue; + cMenuSetupDuplicates *setupMenu = new cMenuSetupDuplicates(this); + setupMenu->SetTitle(cString::sprintf("%s - %s", tr("Duplicate recordings"), trVDR("Setup"))); + return AddSubMenu(setupMenu); +} + eOSState cMenuDuplicates::Info(void) { if (HasSubMenu() || Count() == 0) @@ -365,8 +423,11 @@ eOSState cMenuDuplicates::ProcessKey(eKeys Key) if (state == osUnknown) { switch (Key) { - case kOk: return Info(); + case kPlay: + case kRed: return Play(); + case kGreen: return Setup(); case kYellow: return Delete(); + case kOk: case kInfo: case kBlue: return Info(); case kNone: if (Recordings.StateChanged(recordingsState)) @@ -381,3 +442,26 @@ eOSState cMenuDuplicates::ProcessKey(eKeys Key) } return state; } + +// --- cMenuSetupDuplicates -------------------------------------------------- + +cMenuSetupDuplicates::cMenuSetupDuplicates(cMenuDuplicates *MenuDuplicates) +{ + menuDuplicates = MenuDuplicates; + Add(new cMenuEditBoolItem(tr("Compare title"), &dc.title)); +} + +void cMenuSetupDuplicates::Store(void) +{ + dc.Store(); + if (menuDuplicates != NULL) + { + menuDuplicates->SetCurrent(NULL); + menuDuplicates->Set(); + } +} + +void cMenuSetupDuplicates::SetTitle(const char *Title) +{ + cMenuSetupPage::SetTitle(Title); +} @@ -13,17 +13,23 @@ #include <vdr/osdbase.h> #include <vdr/recording.h> +#include <vdr/menuitems.h> +#include "config.h" class cMenuDuplicateItem; +class cMenuSetupDuplicates; // --- cMenuDuplicates ------------------------------------------------------- class cMenuDuplicates : public cOsdMenu { + friend class cMenuSetupDuplicates; private: int recordingsState; int helpKeys; void SetHelpKeys(void); void Set(bool Refresh = false); + eOSState Play(void); + eOSState Setup(void); eOSState Delete(void); eOSState Info(void); protected: @@ -34,4 +40,16 @@ public: virtual eOSState ProcessKey(eKeys Key); }; +// --- cMenuSetupDuplicates -------------------------------------------------- + +class cMenuSetupDuplicates : public cMenuSetupPage { +private: + cMenuDuplicates *menuDuplicates; +protected: + virtual void Store(void); +public: + cMenuSetupDuplicates(cMenuDuplicates *menuDuplicates = NULL); + void SetTitle(const char *Title); + }; + #endif diff --git a/po/de_DE.po b/po/de_DE.po index d99ee13..6bb0606 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr-duplicates 0.0.1\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2011-06-02 19:48+0300\n" +"POT-Creation-Date: 2011-12-20 18:14+0200\n" "PO-Revision-Date: 2011-06-05 23:37+0100\n" "Last-Translator: Reiner Paulus <flex0r@gmx.net>\n" "Language-Team: \n" @@ -34,3 +34,5 @@ msgstr "%d doppelte Aufnahmen" msgid "%d recordings without description" msgstr "%d Aufnahmen ohne Beschreibung" +msgid "Compare title" +msgstr "" diff --git a/po/fi_FI.po b/po/fi_FI.po index e4d42cc..7810ac4 100644 --- a/po/fi_FI.po +++ b/po/fi_FI.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: vdr-duplicates 0.0.1\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2011-06-02 19:48+0300\n" -"PO-Revision-Date: 2011-05-26 22:35+0300\n" +"POT-Creation-Date: 2011-12-20 18:14+0200\n" +"PO-Revision-Date: 2011-12-12 19:57+0300\n" "Last-Translator: Timo Eskola <timo@tolleri.net>\n" "Language-Team: Finnish\n" "Language: \n" @@ -31,3 +31,6 @@ msgstr "%d päällekkäistä tallennetta" #, c-format msgid "%d recordings without description" msgstr "%d tallennetta ilman kuvausta" + +msgid "Compare title" +msgstr "Vertaa otsikkoa" diff --git a/po/it_IT.po b/po/it_IT.po index 5c01a63..418fcff 100644 --- a/po/it_IT.po +++ b/po/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr-duplicates 0.0.1\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2011-06-02 19:48+0300\n" +"POT-Creation-Date: 2011-12-20 18:14+0200\n" "PO-Revision-Date: 2011-06-05 23:37+0100\n" "Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n" "Language-Team: \n" @@ -35,3 +35,5 @@ msgstr "%d registrazioni duplicate" msgid "%d recordings without description" msgstr "%d registrazioni senza descrizione" +msgid "Compare title" +msgstr "" |