diff options
author | Martin Prochnow <nordlicht@martins-kabuff.de> | 2006-03-12 18:14:36 +0100 |
---|---|---|
committer | Andreas Mair <andreas@vdr-developer.org> | 2006-03-12 18:14:36 +0100 |
commit | 17f89bafd559b28b5a175aa82730226dfe9f7d69 (patch) | |
tree | 7098824c14f462d44eaaccf5dc4c6975673ed275 | |
parent | babfdd26f9d2fbe164205951413d74aa6d21ef23 (diff) | |
download | vdr-plugin-extrecmenu-17f89bafd559b28b5a175aa82730226dfe9f7d69.tar.gz vdr-plugin-extrecmenu-17f89bafd559b28b5a175aa82730226dfe9f7d69.tar.bz2 |
Version 0.3v0.3
- details for directories are shown now (# of entries, # of new entries)
- option to shown the length of a recording
- option to hide recording date, time and/or length
-rw-r--r-- | HISTORY | 9 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | extrecmenu.c | 16 | ||||
-rw-r--r-- | extrecmenu.h | 7 | ||||
-rw-r--r-- | i18n.c | 9 | ||||
-rw-r--r-- | mymenurecordings.c | 129 | ||||
-rw-r--r-- | mymenusetup.c | 22 | ||||
-rw-r--r-- | mymenusetup.h | 21 |
8 files changed, 175 insertions, 40 deletions
@@ -1,13 +1,18 @@ VDR Plugin 'extrecmenu' Revision History ---------------------------------------- +2006-03-12: Version 0.3 +- details for directories are shown now (# of entries, # of new entries) +- option to shown the length of a recording +- option to hide recording date, time and/or length + 2006-03-11: Version 0.2 - implemented own dvbplayercontrol-class so that people who haved patch their vdr with the jumpplay-patch can compile the plugin - 'Info' while replaying opens recording info -- option 'Info' added to recordings list to schow the description of a +- option 'Info' added to recordings list to show the description of a recording -- details (date and time) of recordings are shown now +- details (date and time) for recordings are shown now 2006-03-09: Version 0.1 - Initial revision. @@ -47,7 +47,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): OBJS = $(PLUGIN).o mymenurecordings.o myreplaycontrol.o mymenurenamerecording.o \ - mymenumoverecording.o i18n.o mydvbplayer.o mymenurecordinginfo.o + mymenumoverecording.o i18n.o mydvbplayer.o mymenurecordinginfo.o mymenusetup.o ### Implicit rules: diff --git a/extrecmenu.c b/extrecmenu.c index 0adf67e..dc94164 100644 --- a/extrecmenu.c +++ b/extrecmenu.c @@ -1,4 +1,5 @@ #include "extrecmenu.h" +#include "mymenusetup.h" cPluginExtrecmenu::cPluginExtrecmenu(void) { @@ -55,13 +56,22 @@ cOsdObject *cPluginExtrecmenu::MainMenuAction(void) cMenuSetupPage *cPluginExtrecmenu::SetupMenu(void) { // Return a setup menu in case the plugin supports one. - return NULL; + return new myMenuSetup(); } bool cPluginExtrecmenu::SetupParse(const char *Name, const char *Value) { - // Parse your own setup parameters and store their values. - return false; + if(!strcasecmp(Name,"ShowRecDate")) + mysetup.ShowRecDate=atoi(Value); + else + if(!strcasecmp(Name,"ShowRecTime")) + mysetup.ShowRecTime=atoi(Value); + else + if(!strcasecmp(Name,"ShowRecLength")) + mysetup.ShowRecLength=atoi(Value); + else + return false; + return true; } bool cPluginExtrecmenu::Service(const char *Id, void *Data) diff --git a/extrecmenu.h b/extrecmenu.h index 64e864f..139dcd8 100644 --- a/extrecmenu.h +++ b/extrecmenu.h @@ -4,7 +4,7 @@ #include <vdr/videodir.h> #include "i18n.h" -static const char *VERSION = "0.2"; +static const char *VERSION = "0.3"; static const char *DESCRIPTION = "Extended recordings menu"; static const char *MAINMENUENTRY = "ExtRecMenu"; @@ -39,6 +39,7 @@ class myMenuRecordingsItem:public cOsdItem { private: int level,isdirectory; + int totalentries,newentries; char *title; char *name; const char *filename; @@ -48,6 +49,7 @@ class myMenuRecordingsItem:public cOsdItem const char *FileName(){return filename;} const char *Name(){return name;} bool IsDirectory(){return name!=NULL;} + void IncrementCounter(bool IsNew); }; // --- myMenuRecordings ------------------------------------------------------- @@ -56,6 +58,7 @@ class myMenuRecordings:public cOsdMenu private: bool edit; int level,helpkeys; + int recordingsstate; char *base; bool Open(); void SetHelpKeys(); @@ -69,7 +72,7 @@ class myMenuRecordings:public cOsdMenu public: myMenuRecordings(const char *Base=NULL,int Level=0); ~myMenuRecordings(); - void Set(); + void Set(bool Refresh=false); virtual eOSState ProcessKey(eKeys Key); }; @@ -47,5 +47,14 @@ const tI18nPhrase Phrases[] = { { "Rename recording", "Aufzeichnung umbenennen", }, + { "Show recording date", + "Zeige Aufnahmedatum", + }, + { "Show recording time", + "Zeige Aufnahmezeit", + }, + { "Show recording length", + "Zeige Aufnahmelänge", + }, { NULL } }; diff --git a/mymenurecordings.c b/mymenurecordings.c index 3c5f76f..b29242e 100644 --- a/mymenurecordings.c +++ b/mymenurecordings.c @@ -1,8 +1,11 @@ #include "mymenurecordings.h" +#include "mymenusetup.h" // --- myMenuRecordingsItem --------------------------------------------------- myMenuRecordingsItem::myMenuRecordingsItem(cRecording *Recording,int Level) { + totalentries=newentries=0; + char isnew=Recording->IsNew()?'*':' '; name=NULL; filename=Recording->FileName(); @@ -17,7 +20,7 @@ myMenuRecordingsItem::myMenuRecordingsItem(cRecording *Recording,int Level) } // create the title of this item - if(Level<level) + if(Level<level) // directory entries { s=Recording->Name(); while(Level) @@ -25,30 +28,61 @@ myMenuRecordingsItem::myMenuRecordingsItem(cRecording *Recording,int Level) s=strchr(Recording->Name(),'~')+1; Level--; } - title=strdup(s); + asprintf(&title,"\t\t%s",s); char *p=strchr(title,'~'); if(p) *p=0; - name=strdup(title); + name=strdup(title+2); } else - if(Level==level) + if(Level==level) // recording entries { s=strrchr(Recording->Name(),'~'); - struct tm tm_tmp; - localtime_r(&Recording->start,&tm_tmp); - asprintf(&title,"%02d.%02d.%02d\t%02d:%02d%c\t%s", - tm_tmp.tm_mday, - tm_tmp.tm_mon+1, - tm_tmp.tm_year%100, - tm_tmp.tm_hour, - tm_tmp.tm_min, - isnew, - s?s+1:Recording->Name()); + // date and time of recording + struct tm t; + localtime_r(&Recording->start,&t); + + // recording length + struct tIndex{int offset;uchar type;uchar number;short reserved;}; + char RecLength[21],RecDate[9],RecTime[6],RecDelimiter[2]={'\t',0}; + int last=-1; + char *indexfilename; + + asprintf(&indexfilename,"%s/index.vdr",filename); + int delta=0; + if(!access(indexfilename,R_OK)) + { + struct stat buf; + if(!stat(indexfilename,&buf)) + { + delta=buf.st_size%sizeof(tIndex); + if(delta) + delta=sizeof(tIndex)-delta; + last=(buf.st_size+delta)/sizeof(tIndex)+1; + char hour[2],min[3]; + snprintf(RecLength,sizeof(RecLength),"%s",*IndexToHMSF(last,true)); + snprintf(hour,sizeof(hour),"%c",RecLength[0]); + snprintf(min,sizeof(min),"%c%c",RecLength[2],RecLength[3]); + snprintf(RecLength,sizeof(RecLength),"%d'",(atoi(hour)*60)+atoi(min)); + } + } + free(indexfilename); + + snprintf(RecDate,sizeof(RecDate),"%02d.%02d.%02d",t.tm_mday,t.tm_mon,t.tm_year%100); + snprintf(RecTime,sizeof(RecTime),"%02d:%02d",t.tm_hour,t.tm_min); + asprintf(&title,"%s%s%s%s%s%s%c%s", + (mysetup.ShowRecDate?RecDate:""), + (mysetup.ShowRecDate?RecDelimiter:""), + (mysetup.ShowRecTime?RecTime:""), + (mysetup.ShowRecTime?RecDelimiter:""), + (mysetup.ShowRecLength?RecLength:""), + (mysetup.ShowRecLength?RecDelimiter:""), + isnew, + s?s+1:Recording->Name()); } else - if(Level>level) + if(Level>level) // any other { title=""; } @@ -62,16 +96,29 @@ myMenuRecordingsItem::~myMenuRecordingsItem() free(name); } +void myMenuRecordingsItem::IncrementCounter(bool IsNew) +{ + totalentries++; + if(IsNew) + newentries++; + + char *buffer=NULL; + asprintf(&buffer,"%d\t%d\t%s",totalentries,newentries,name); + SetText(buffer,false); +} + // --- myMenuRecordings ------------------------------------------------------- -myMenuRecordings::myMenuRecordings(const char *Base,int Level):cOsdMenu(Base?Base:tr(DESCRIPTION),8,6) +myMenuRecordings::myMenuRecordings(const char *Base,int Level):cOsdMenu(Base?Base:tr(DESCRIPTION),8,6,4) { edit=false; level=Level; helpkeys=-1; base=Base?strdup(Base):NULL; - Display(); + Recordings.StateChanged(recordingsstate); + Set(); + Display(); SetHelpKeys(); } @@ -80,48 +127,61 @@ myMenuRecordings::~myMenuRecordings() free(base); } -void myMenuRecordings::Set() +void myMenuRecordings::Set(bool Refresh) { - char *lastitemtext=NULL; - cThreadLock RecordingsLock(&Recordings); Clear(); Recordings.Sort(); + char *lastitemtext=NULL; + myMenuRecordingsItem *lastitem=NULL; // add first the directories for(cRecording *recording=Recordings.First();recording;recording=Recordings.Next(recording)) { if(!base||(strstr(recording->Name(),base)==recording->Name()&&recording->Name()[strlen(base)]=='~')) { myMenuRecordingsItem *item=new myMenuRecordingsItem(recording,level); - if(item->IsDirectory()&&*item->Text()&&(!lastitemtext||strcmp(lastitemtext,item->Text()))) + if(*item->Text()&&(!lastitem||strcmp(item->Text(),lastitemtext))) { - Add(item); + if(item->IsDirectory()) + Add(item); + + lastitem=item; free(lastitemtext); - lastitemtext=strdup(item->Text()); + lastitemtext=strdup(lastitem->Text()); } else delete item; + + if(lastitem) + { + if(lastitem->IsDirectory()) + lastitem->IncrementCounter(recording->IsNew()); // counts the number of entries in a directory + } } } + lastitem=NULL; // and now the recordings for(cRecording *recording=Recordings.First();recording;recording=Recordings.Next(recording)) { if(!base||(strstr(recording->Name(),base)==recording->Name()&&recording->Name()[strlen(base)]=='~')) { myMenuRecordingsItem *item=new myMenuRecordingsItem(recording,level); - if(!item->IsDirectory()&&*item->Text()&&(!lastitemtext||strcmp(lastitemtext,item->Text()))) + if(*item->Text()&&(!lastitem||strcmp(lastitemtext,item->Text()))) { - Add(item); + if(!item->IsDirectory()) + Add(item); + lastitem=item; free(lastitemtext); - lastitemtext=strdup(item->Text()); + lastitemtext=strdup(lastitem->Text()); } else delete item; } } free(lastitemtext); - Display(); + if(Refresh) + Display(); } void myMenuRecordings::SetHelpKeys() @@ -153,6 +213,7 @@ void myMenuRecordings::SetHelpKeys() } } +// returns the corresponding recording to an item cRecording *myMenuRecordings::GetRecording(myMenuRecordingsItem *Item) { cRecording *recording=Recordings.GetByName(Item->FileName()); @@ -161,6 +222,7 @@ cRecording *myMenuRecordings::GetRecording(myMenuRecordingsItem *Item) return recording; } +// opens a subdirectory bool myMenuRecordings::Open() { myMenuRecordingsItem *item=(myMenuRecordingsItem*)Get(Current()); @@ -180,6 +242,7 @@ bool myMenuRecordings::Open() return false; } +// plays a recording eOSState myMenuRecordings::Play() { myMenuRecordingsItem *item=(myMenuRecordingsItem*)Get(Current()); @@ -202,6 +265,7 @@ eOSState myMenuRecordings::Play() return osContinue; } +// plays a recording from the beginning eOSState myMenuRecordings::Rewind() { if(HasSubMenu()||Count()==0) @@ -218,6 +282,7 @@ eOSState myMenuRecordings::Rewind() return osContinue; } +// delete a recording eOSState myMenuRecordings::Delete() { if(HasSubMenu()||Count()==0) @@ -270,6 +335,7 @@ eOSState myMenuRecordings::Delete() return osContinue; } +// renames a recording eOSState myMenuRecordings::Rename() { if(HasSubMenu()||Count()==0) @@ -285,6 +351,7 @@ eOSState myMenuRecordings::Rename() return osContinue; } +// moves a recording eOSState myMenuRecordings::MoveRec() { if(HasSubMenu()||Count()==0) @@ -303,6 +370,7 @@ eOSState myMenuRecordings::MoveRec() return osContinue; } +// opens an info screen to a recording eOSState myMenuRecordings::Info(void) { if(HasSubMenu()||Count()==0) @@ -344,7 +412,6 @@ eOSState myMenuRecordings::ProcessKey(eKeys Key) } else { - bool hadsubmenu=HasSubMenu(); state=cOsdMenu::ProcessKey(Key); if(state==osUnknown) { @@ -363,13 +430,11 @@ eOSState myMenuRecordings::ProcessKey(eKeys Key) break; } case kBlue: return Info(); + case kNone: if(Recordings.StateChanged(recordingsstate)) + Set(true); default: break; } } - // refresh the list after submenu has closed - if(hadsubmenu&&!HasSubMenu()) - Set(); - // go back if list is empty if(!Count()) state=osBack; diff --git a/mymenusetup.c b/mymenusetup.c new file mode 100644 index 0000000..2f3ae40 --- /dev/null +++ b/mymenusetup.c @@ -0,0 +1,22 @@ +#include <vdr/menu.h> +#include "mymenusetup.h" + +mySetup mysetup; + +myMenuSetup::myMenuSetup() +{ + showrecdate=mysetup.ShowRecDate; + showrectime=mysetup.ShowRecTime; + showreclength=mysetup.ShowRecLength; + + Add(new cMenuEditBoolItem(tr("Show recording date"),&showrecdate)); + Add(new cMenuEditBoolItem(tr("Show recording time"),&showrectime)); + Add(new cMenuEditBoolItem(tr("Show recording length"),&showreclength)); +} + +void myMenuSetup::Store() +{ + SetupStore("ShowRecDate",mysetup.ShowRecDate=showrecdate); + SetupStore("ShowRecTime",mysetup.ShowRecTime=showrectime); + SetupStore("ShowRecLength",mysetup.ShowRecLength=showreclength); +} diff --git a/mymenusetup.h b/mymenusetup.h new file mode 100644 index 0000000..b137789 --- /dev/null +++ b/mymenusetup.h @@ -0,0 +1,21 @@ +class mySetup +{ + public: + int ShowRecDate; + int ShowRecTime; + int ShowRecLength; +}; + +extern mySetup mysetup; + +class myMenuSetup:public cMenuSetupPage +{ + private: + int showrecdate; + int showrectime; + int showreclength; + protected: + virtual void Store(); + public: + myMenuSetup(); +}; |