diff options
author | Thomas Maass <mase@mase1.setho.org> | 2013-10-21 17:55:03 +0200 |
---|---|---|
committer | Thomas Maass <mase@mase1.setho.org> | 2013-10-21 17:55:03 +0200 |
commit | 526f69027750591f7196e0c3bd311936dc2610c5 (patch) | |
tree | 5e61f9ad96bf37eb3b211f23bf8471c62a424b0f | |
parent | e8d1ca5ff467ab26c94513ca671f7ea626d9a9c4 (diff) | |
download | vdr-plugin-hddarchive-526f69027750591f7196e0c3bd311936dc2610c5.tar.gz vdr-plugin-hddarchive-526f69027750591f7196e0c3bd311936dc2610c5.tar.bz2 |
Removed archive functions from cMyMenuRecordingItem.
They are now called, when a cRecording is used.
Removed support for VDR < 2.1.2.
Fixed Play service.
Fixed VDR patch.
Added Skinnopacity patch.
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | archive.c | 2 | ||||
-rw-r--r-- | hddarchive.c | 7 | ||||
-rw-r--r-- | mymenu.c | 64 | ||||
-rw-r--r-- | mymenu.h | 40 | ||||
-rw-r--r-- | patches/skinnopacity-hddarchive.patch | 74 | ||||
-rw-r--r-- | patches/vdr-2.1.1-hddarchive-0.0.1.patch | 71 | ||||
-rw-r--r-- | patches/vdr-hddarchive.patch (renamed from patches/vdr-2.0.3-hddarchive-0.0.1.patch) | 43 | ||||
-rwxr-xr-x | setup.c | 4 |
9 files changed, 170 insertions, 137 deletions
@@ -13,7 +13,7 @@ the Free Software Foundation; either version 2 of the License, or See the file COPYING for more information. Requirements -- VDR version >= 1.7.34 +- VDR version >= 2.1.2 - Optional patch to integrate into VDRs original recmenu @@ -10,7 +10,7 @@ #include <vdr/videodir.h> #include "archive.h" -// --- cArchive ----------------------------------------------------------- +// --- cArchive ---------------------------------------------------------------- cString cArchive::archivePath = NULL; char cArchive::buf[8] = ""; diff --git a/hddarchive.c b/hddarchive.c index ecefac6..ff23775 100644 --- a/hddarchive.c +++ b/hddarchive.c @@ -115,7 +115,7 @@ struct Hddarchive_archiveid_v1_0 struct Hddarchive_play_v1_0 { - cMenuRecordingItem *item; + const cRecording *recording; }; bool cPluginHddarchive::Service(const char *Id, void *Data) @@ -128,14 +128,13 @@ bool cPluginHddarchive::Service(const char *Id, void *Data) archive->isarchive = strcmp(archive->archiveid, "") ? true : false; return true; } - + if (!strcmp(Id, "Hddarchive-play_v1.0")) { if (Data == NULL) return false; Hddarchive_play_v1_0 *play = (Hddarchive_play_v1_0 *)Data; cMyMenuRecordings player(NULL, 0, false, false); - player.SetCurrent((cOsdItem *)play->item, false); - player.ProcessKey(kRed); + player.Play(play->recording, false); return true; } return false; @@ -8,7 +8,7 @@ #include "mymenu.h" -// --- cMyMenuRecordings -------------------------------------------------- +// --- cMyMenuRecordings ------------------------------------------------------- cMyMenuRecordings::cMyMenuRecordings(const char *Base, int Level, bool OpenSubMenus, bool Show) : cOsdMenu(Base ? Base : tr("HDD-Archive"), 9, 6, 6), show(Show) @@ -16,7 +16,6 @@ cMyMenuRecordings::cMyMenuRecordings(const char *Base, int Level, bool OpenSubMe SetMenuCategory(mcRecording); base = Base ? strdup(Base) : NULL; level = Setup.RecordingDirs ? Level : -1; - isPluginReplay = true; Recordings.StateChanged(recordingsState); // just to get the current state helpKeys = -1; if (show) @@ -39,7 +38,7 @@ cMyMenuRecordings::~cMyMenuRecordings() void cMyMenuRecordings::SetHelpKeys(void) { - cMyMenuRecordingItem *ri = (cMyMenuRecordingItem *)Get(Current()); + cMyMenuRecordingItem *ri = (cMyMenuRecordingItem *)Get(Current()); int NewHelpKeys = 0; if (ri) { if (ri->IsDirectory()) @@ -112,7 +111,7 @@ void cMyMenuRecordings::Set(bool Refresh) cString cMyMenuRecordings::DirectoryName(void) { - cString d(VideoDirectory); + cString d(cVideoDirectory::Name()); if (base) { char *s = ExchangeChars(strdup(base), true); d = AddDirectory(d, s); @@ -137,17 +136,12 @@ bool cMyMenuRecordings::Open(bool OpenSubMenus) return false; } -void cMyMenuRecordings::SetCurrent(cOsdItem *Item, bool IsPluginReplay) -{ - cOsdMenu::SetCurrent(Item); - isPluginReplay = IsPluginReplay; -} - -bool cMyMenuRecordings::Prepare(cMyMenuRecordingItem *Ri) +bool cMyMenuRecordings::Prepare(const cRecording *Recording) { - if (Ri->IsArchive()) { + const char *archiveId = cArchive::GetArchiveId(Recording); + if (strcmp(archiveId, "")) { char *msg = NULL; - asprintf(&msg, tr("Please attach archive-hdd %s"), Ri->ArchiveId()); + asprintf(&msg, tr("Please attach archive-hdd %s"), archiveId); if (!Interface->Confirm(msg)) { free(msg); return false; @@ -157,7 +151,7 @@ bool cMyMenuRecordings::Prepare(cMyMenuRecordingItem *Ri) Skins.Message(mtError, tr("Could not mount archive-hdd!")); return false; } - if (!cArchive::LinkArchive(Ri->Recording())) { + if (!cArchive::LinkArchive(Recording)) { Skins.Message(mtError, tr("Recording not found!")); cArchive::UnmountArchive(); return false; @@ -172,11 +166,18 @@ eOSState cMyMenuRecordings::Play(void) if (ri) { if (ri->IsDirectory()) Open(); - else if (Prepare(ri)) { - cMyReplayControl::SetRecording(ri->Recording()->FileName()); - cControl::Launch(new cMyReplayControl(isPluginReplay)); + else + return Play(ri->Recording(), true); + } + return osContinue; +} + +eOSState cMyMenuRecordings::Play(const cRecording *Recording, bool IsPluginReplay) +{ + if (Prepare(Recording)) { + cMyReplayControl::SetRecording(Recording->FileName()); + cControl::Launch(new cMyReplayControl(IsPluginReplay)); return osEnd; - } } return osContinue; } @@ -204,9 +205,12 @@ eOSState cMyMenuRecordings::Info(void) { if (HasSubMenu() || Count() == 0) return osContinue; - cMyMenuRecordingItem *ri = (cMyMenuRecordingItem *)Get(Current()); - if (ri && !ri->IsDirectory() && ri->Recording()->Info()->Title()) - return AddSubMenu(new cMenuRecording(ri->Recording(), true)); + if (cMyMenuRecordingItem *ri = (cMyMenuRecordingItem *)Get(Current())) { + if (ri->IsDirectory()) + return AddSubMenu(new cMenuPathEdit(cString(ri->Recording()->Name(), strchrn(ri->Recording()->Name(), FOLDERDELIMCHAR, ri->Level() + 1)))); + else + return AddSubMenu(new cMenuRecording(ri->Recording(), true)); + } return osContinue; } @@ -253,22 +257,14 @@ eOSState cMyMenuRecordings::ProcessKey(eKeys Key) return state; } -// --- cMyMenuRecordingItem ----------------------------------------------- +// --- cMyMenuRecordingItem ---------------------------------------------------- cMyMenuRecordingItem::cMyMenuRecordingItem(cRecording *Recording, int Level) : recording(Recording), level(Level) { name = NULL; - archiveId = NULL; - uniqueFolder = NULL; totalEntries = newEntries = 0; - // get the archive-id - archiveId = strdup(cArchive::GetArchiveId(recording)); - if (strcmp(archiveId, "")) - isArchive = true; - // get the unique folder name, like "2013-06-03.21.05.141-0.rec" - uniqueFolder = strdup(strrchr(recording->FileName(), '/') + 1); - //replace newindicator with '#' for archives - if (isArchive && (level < 0 || level == recording->HierarchyLevels())) { + // replace newindicator with '#' for archives + if (strcmp(cArchive::GetArchiveId(Recording), "") && (level < 0 || level == recording->HierarchyLevels())) { char *text = strdup(recording->Title('\t', true, level)); int nipos = strlen(strrchr(recording->Title('\t', true, level), '\t') + 1); text[strlen(recording->Title('\t', true, level)) - nipos - 2] = '#'; @@ -284,8 +280,6 @@ cMyMenuRecordingItem::cMyMenuRecordingItem(cRecording *Recording, int Level) : r cMyMenuRecordingItem::~cMyMenuRecordingItem() { free(name); - free(archiveId); - free(uniqueFolder); } void cMyMenuRecordingItem::IncrementCounter(bool New) @@ -302,7 +296,7 @@ void cMyMenuRecordingItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, DisplayMenu->SetItem(Text(), Index, Current, Selectable); } -// --- cMyReplayControl --------------------------------------------------- +// --- cMyReplayControl -------------------------------------------------------- cMyReplayControl::cMyReplayControl(bool IsPluginReplay) : isPluginReplay(IsPluginReplay) @@ -28,12 +28,11 @@ class cMyMenuRecordings : public cOsdMenu { bool show; int recordingsState; int helpKeys; - bool isPluginReplay; void SetHelpKeys(void); void Set(bool Refresh = false); cString DirectoryName(void); bool Open(bool OpenSubMenus = false); - bool Prepare(cMyMenuRecordingItem *Ri); + bool Prepare(const cRecording *Recording); eOSState Play(void); eOSState Rewind(void); eOSState Archive(void); @@ -41,10 +40,10 @@ class cMyMenuRecordings : public cOsdMenu { eOSState Sort(void); public: cMyMenuRecordings(const char *Base = NULL, int Level = 0, bool OpenSubMenus = false, bool Show = true); - // when Show = false, the menu works in background wothout being displayed + // when Show = false, the menu works in background without being displayed virtual ~cMyMenuRecordings(); - virtual void SetCurrent(cOsdItem *Item, bool IsPluginReplay = true); virtual eOSState ProcessKey(eKeys Key); + eOSState Play(const cRecording *Recording, bool IsPluginReplay = true); }; class cMyMenuRecordingItem : public cOsdItem { @@ -54,32 +53,26 @@ class cMyMenuRecordingItem : public cOsdItem { char *name; int totalEntries; int newEntries; - bool isArchive = false; - bool isMounted = false; - bool isLinked = false; - char *archiveId; - char *uniqueFolder; public: cMyMenuRecordingItem(cRecording *Recording, int Level); virtual ~cMyMenuRecordingItem(); void IncrementCounter(bool New); virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable); const char *Name(void) { return name; } + int Level(void) { return level; } cRecording *Recording(void) { return recording; } bool IsDirectory(void) { return name != NULL; } - bool IsArchive(void) { return isArchive; } - bool IsMounted(void) { return isMounted; } - bool IsLinked(void) { return isLinked; } - const char *ArchiveId(void) { return archiveId; } - const char *UniqueFolder(void) { return uniqueFolder; } }; class cMenuRecording : public cOsdMenu { private: - const cRecording *recording; + cRecording *recording; + cString originalFileName; + int recordingsState; bool withButtons; + bool RefreshRecording(void); public: - cMenuRecording(const cRecording *Recording, bool WithButtons = false); + cMenuRecording(cRecording *Recording, bool WithButtons = false); virtual void Display(void); virtual eOSState ProcessKey(eKeys Key); }; @@ -92,4 +85,19 @@ class cMyReplayControl : public cReplayControl { virtual ~cMyReplayControl(); }; +class cMenuPathEdit : public cOsdMenu { + private: + cString path; + char folder[PATH_MAX]; + char name[NAME_MAX]; + cMenuEditStrItem *folderItem; + int pathIsInUse; + eOSState SetFolder(void); + eOSState Folder(void); + eOSState ApplyChanges(void); + public: + cMenuPathEdit(const char *Path); + virtual eOSState ProcessKey(eKeys Key); +}; + #endif // __MYMENU_H diff --git a/patches/skinnopacity-hddarchive.patch b/patches/skinnopacity-hddarchive.patch new file mode 100644 index 0000000..098ab49 --- /dev/null +++ b/patches/skinnopacity-hddarchive.patch @@ -0,0 +1,74 @@ +--- menuitem.c 2013-10-19 19:59:29.867915217 +0200 ++++ menuitem.c 2013-10-19 19:56:14.335920540 +0200 +@@ -1,4 +1,5 @@ + #include "menuitem.h" ++#include "services/hddarchive.h" + #include <string> + #include <sstream> + #include <algorithm> +@@ -1154,7 +1155,6 @@ + + void cNopacityRecordingMenuItem::DrawRecordingNewIcon(void) { + int iconNewSize = height/3; +- + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/newrecording", iconNewSize, iconNewSize); + if (imgIcon) { + int iconX = pixmapIcon->ViewPort().Width() - iconNewSize; +@@ -1175,6 +1175,16 @@ + } + } + ++void cNopacityRecordingMenuItem::DrawRecordingArchiveIcon(void) { ++ int iconArchiveSize = height/3; ++ cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/archive", iconArchiveSize, iconArchiveSize); ++ if (imgIcon) { ++ int iconX = pixmapIcon->ViewPort().Width() - iconArchiveSize; ++ int iconY = height/2; ++ pixmapIcon->DrawImage(cPoint(iconX, iconY), *imgIcon); ++ } ++} ++ + void cNopacityRecordingMenuItem::DrawFolderIcon(void) { + cImage *imgIcon = imgCache->GetSkinIcon("skinIcons/recfolder", posterWidth, posterHeight); + if (imgIcon) { +@@ -1243,9 +1253,19 @@ + DrawFolderNewSeen(); + SetTextShort(); + } else { ++ cPlugin *hddarchivePlugin = cPluginManager::GetPlugin("hddarchive"); ++ Hddarchive_archiveid_v1_0 data; ++ data.recording = Recording; ++ data.isarchive = false; ++ if (hddarchivePlugin) { ++ hddarchivePlugin->Service("Hddarchive-archiveid_v1.0", &data); ++ } + DrawPoster(); + DrawRecDateTime(); +- if (Recording->IsNew()) { ++ if (data.isarchive) { ++ DrawRecordingArchiveIcon(); ++ } ++ else if (Recording->IsNew()) { + DrawRecordingNewIcon(); + } + if (Recording->IsEdited()) { +--- menuitem.h 2013-10-19 19:59:29.867915217 +0200 ++++ menuitem.h 2013-10-19 19:56:14.335920540 +0200 +@@ -173,6 +173,7 @@ + void SetTextShortRecording(void); + void DrawBackground(void); + void DrawRecordingNewIcon(void); ++ void DrawRecordingArchiveIcon(void); + void DrawRecordingEditedIcon(void); + void DrawFolderIcon(void); + void DrawRecDateTime(void); +--- services/hddarchive.h 1970-01-01 01:00:00.000000000 +0100 ++++ services/hddarchive.h 2013-10-19 19:46:57.000000000 +0200 +@@ -0,0 +1,7 @@ ++struct Hddarchive_archiveid_v1_0 ++{ ++ const cRecording *recording; ++ bool isarchive; ++ char *archiveid; ++}; ++ diff --git a/patches/vdr-2.1.1-hddarchive-0.0.1.patch b/patches/vdr-2.1.1-hddarchive-0.0.1.patch deleted file mode 100644 index 0226094..0000000 --- a/patches/vdr-2.1.1-hddarchive-0.0.1.patch +++ /dev/null @@ -1,71 +0,0 @@ ---- vdr-2.1.1-orig/menu.c 2013-08-21 12:45:11.000000000 +0200 -+++ vdr-2.1.1/menu.c 2013-09-20 15:33:04.629102337 +0200 -@@ -51,6 +51,18 @@ - #define CHNUMWIDTH (numdigits(Channels.MaxNumber()) + 1) - #define CHNAMWIDTH (min(MAXCHNAMWIDTH, Channels.MaxShortChannelNameLength() + 1)) - -+struct Hddarchive_archiveid_v1_0 -+{ -+ const cRecording *recording; -+ bool isarchive; -+ const char *archiveid; -+}; -+ -+struct Hddarchive_play_v1_0 -+{ -+ cMenuRecordingItem *item; -+}; -+ - // --- cMenuEditCaItem ------------------------------------------------------- - - class cMenuEditCaItem : public cMenuEditIntItem { -@@ -2348,6 +2360,13 @@ - if (ri->IsDirectory()) - Open(); - else { -+ cPlugin *hddarchivePlugin = cPluginManager::GetPlugin("hddarchive"); -+ Hddarchive_play_v1_0 data; -+ data.item = ri; -+ if (hddarchivePlugin) { -+ hddarchivePlugin->Service("Hddarchive-play_v1.0", &data); -+ return osEnd; -+ } - cReplayControl::SetRecording(ri->Recording()->FileName()); - return osReplay; - } -@@ -2374,6 +2393,17 @@ - if (HasSubMenu() || Count() == 0) - return osContinue; - cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current()); -+ cPlugin *hddarchivePlugin = cPluginManager::GetPlugin("hddarchive"); -+ Hddarchive_archiveid_v1_0 data; -+ data.recording = ri->Recording(); -+ data.isarchive = false; -+ if (hddarchivePlugin) { -+ hddarchivePlugin->Service("Hddarchive-archiveid_v1.0", &data); -+ if (data.isarchive) { -+ Skins.Message(mtError, tr("Cannot delete archived recording!")); -+ return osContinue; -+ } -+ } - if (ri && !ri->IsDirectory()) { - if (Interface->Confirm(tr("Delete recording?"))) { - cRecordControl *rc = cRecordControls::GetRecordControl(ri->Recording()->FileName()); -@@ -4854,7 +4884,16 @@ - if (*fileName) { - Hide(); - if (!cCutter::Active()) { -- if (!marks.Count()) -+ cPlugin *hddarchivePlugin = cPluginManager::GetPlugin("hddarchive"); -+ Hddarchive_archiveid_v1_0 data; -+ data.recording = GetRecording(); -+ data.isarchive = false; -+ if (hddarchivePlugin) { -+ hddarchivePlugin->Service("Hddarchive-archiveid_v1.0", &data); -+ } -+ if (data.isarchive) -+ Skins.Message(mtError, tr("Cannot edit archived recording!")); -+ else if (!marks.Count()) - Skins.Message(mtError, tr("No editing marks defined!")); - else if (!marks.GetNumSequences()) - Skins.Message(mtError, tr("No editing sequences defined!")); diff --git a/patches/vdr-2.0.3-hddarchive-0.0.1.patch b/patches/vdr-hddarchive.patch index 55cbef7..5f470d7 100644 --- a/patches/vdr-2.0.3-hddarchive-0.0.1.patch +++ b/patches/vdr-hddarchive.patch @@ -1,6 +1,6 @@ ---- vdr-2.0.3-orig/menu.c 2013-04-27 12:32:28.000000000 +0200 -+++ vdr-2.0.3/menu.c 2013-09-22 18:22:19.440344000 +0200 -@@ -51,6 +51,18 @@ +--- menu.c.orig 2013-10-16 11:15:36.000000000 +0200 ++++ menu.c 2013-10-21 16:09:59.030298758 +0200 +@@ -50,6 +50,18 @@ #define CHNUMWIDTH (numdigits(Channels.MaxNumber()) + 1) #define CHNAMWIDTH (min(MAXCHNAMWIDTH, Channels.MaxShortChannelNameLength() + 1)) @@ -13,19 +13,44 @@ + +struct Hddarchive_play_v1_0 +{ -+ cMenuRecordingItem *item; ++ const cRecording *recording; +}; + // --- cMenuEditCaItem ------------------------------------------------------- class cMenuEditCaItem : public cMenuEditIntItem { -@@ -2348,6 +2360,13 @@ +@@ -2522,7 +2534,23 @@ + level = Level; + name = NULL; + totalEntries = newEntries = 0; +- SetText(Recording->Title('\t', true, Level)); ++ // replace newindicator with '#' for archives ++ cPlugin *hddarchivePlugin = cPluginManager::GetPlugin("hddarchive"); ++ Hddarchive_archiveid_v1_0 data; ++ data.recording = Recording; ++ data.isarchive = false; ++ if (hddarchivePlugin) { ++ hddarchivePlugin->Service("Hddarchive-archiveid_v1.0", &data); ++ } ++ if (data.isarchive && (level < 0 || level == recording->HierarchyLevels())) { ++ char *text = strdup(recording->Title('\t', true, level)); ++ int nipos = strlen(strrchr(recording->Title('\t', true, level), '\t') + 1); ++ text[strlen(recording->Title('\t', true, level)) - nipos - 2] = '#'; ++ SetText(text); ++ free(text); ++ } ++ else ++ SetText(Recording->Title('\t', true, Level)); + if (*Text() == '\t') + name = strdup(Text() + 2); // 'Text() + 2' to skip the two '\t' + } +@@ -2693,6 +2721,13 @@ if (ri->IsDirectory()) Open(); else { + cPlugin *hddarchivePlugin = cPluginManager::GetPlugin("hddarchive"); + Hddarchive_play_v1_0 data; -+ data.item = ri; ++ data.recording = ri->Recording(); + if (hddarchivePlugin) { + hddarchivePlugin->Service("Hddarchive-play_v1.0", &data); + return osEnd; @@ -33,7 +58,7 @@ cReplayControl::SetRecording(ri->Recording()->FileName()); return osReplay; } -@@ -2374,6 +2393,17 @@ +@@ -2719,6 +2754,17 @@ if (HasSubMenu() || Count() == 0) return osContinue; cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current()); @@ -51,10 +76,10 @@ if (ri && !ri->IsDirectory()) { if (Interface->Confirm(tr("Delete recording?"))) { cRecordControl *rc = cRecordControls::GetRecordControl(ri->Recording()->FileName()); -@@ -4832,7 +4862,16 @@ +@@ -5213,7 +5302,16 @@ if (*fileName) { Hide(); - if (!cCutter::Active()) { + if (!RecordingsHandler.GetUsage(fileName)) { - if (!marks.Count()) + cPlugin *hddarchivePlugin = cPluginManager::GetPlugin("hddarchive"); + Hddarchive_archiveid_v1_0 data; @@ -8,6 +8,8 @@ #include "setup.h" +// --- cHddArchiveConfig ------------------------------------------------------- + cHddArchiveConfig::cHddArchiveConfig() { strcpy(ArchiveDevice, "/dev/usb0"); @@ -29,6 +31,8 @@ bool cHddArchiveConfig::SetupParse(const char *Name, const char *Value) return true; } +// --- cHddArchiveSetup -------------------------------------------------------- + cHddArchiveSetup::cHddArchiveSetup() { tmpHddArchiveConfig = HddArchiveConfig; |