OBJECTS1 = main.o command.o log.o tcp.o dsock.o thread.o timers.o i18n.o \
message.o messagequeue.o \
- vdr.o recording.o channel.o rectimer.o event.o directory.o \
+ vdr.o recman.o recording.o channel.o rectimer.o event.o directory.o \
player.o vfeed.o afeed.o afeedr.o \
demuxer.o demuxervdr.o stream.o draintarget.o \
viewman.o box.o region.o colour.o view.o \
#include "directory.h"
-ULONG Directory::totalSpace = 0;
-ULONG Directory::freeSpace = 0;
-ULONG Directory::usedPercent = 0;
-
-Directory::Directory()
+Directory::Directory(char* newName)
{
- name = NULL;
-
- isRoot = 0;
index = -1;
+
+ name = new char[strlen(newName) + 1];
+ strcpy(name, newName);
+
+ parent = NULL;
}
Directory::~Directory()
{
if (name) delete[] name;
+ name = NULL;
index = -1; // just in case
UINT i;
recList.clear();
}
-void Directory::setName(char* newName)
-{
- name = new char[strlen(newName) + 1];
- strcpy(name, newName);
-}
-
Directory* Directory::getDirByName(char* dirName)
{
for(UINT i = 0; i < dirList.size(); i++)
return recList.size();
}
-// FIXME make an add function in here that adds recs to the end of the list
+void Directory::sort()
+{
+ // Sort the directory order
+ ::sort(dirList.begin(), dirList.end(), DirectorySorter());
+
+ // Sort the recordings order
+ ::sort(recList.begin(), recList.end(), RecordingSorter());
+
+ // Now get the dirs to sort themselves! oh I love recursion.
+ for(UINT i = 0; i < dirList.size(); i++) dirList[i]->sort();
+}
#include <stdio.h>
#include <vector>
+#include <algorithm>
using namespace std;
#include "defines.h"
class Directory
{
public:
- Directory();
+ Directory(char* newName);
~Directory();
- void setName(char* newName);
Directory* getDirByName(char* dirName);
- void setFreeSpace(ULLONG);
ULONG getNumRecordings();
+ void sort();
- UCHAR isRoot;
char* name;
int index;
+ Directory* parent;
DirectoryList dirList;
RecordingList recList;
- static ULONG totalSpace;
- static ULONG freeSpace;
- static ULONG usedPercent;
+};
+struct DirectorySorter
+{
+ bool operator() (const Directory* a, const Directory* b)
+ {
+ int c = strcmp(b->name, a->name);
+ if (c > 0) return true;
+ return false;
+ }
+};
+
+struct RecordingSorter
+{
+ bool operator() (const Recording* a, const Recording* b)
+ {
+ int c = strcmp(b->getProgName(), a->getProgName());
+ if (c > 0) return true;
+ if (c < 0) return false;
+
+ return a->getStartTime() < b->getStartTime();
+ }
};
#endif
--- /dev/null
+/*
+ Copyright 2006 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with VOMP; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "recman.h"
+#include "vdr.h"
+
+RecMan::RecMan()
+{
+ totalSpace = 0;
+ freeSpace = 0;
+ usedPercent = 0;
+
+ rootDir = new Directory("/");
+ currentDir = rootDir;
+}
+
+RecMan::~RecMan()
+{
+ delete rootDir;
+}
+
+void RecMan::setStats(ULONG ttotalSpace, ULONG tfreeSpace, ULONG tusedPercent)
+{
+ totalSpace = ttotalSpace;
+ freeSpace = tfreeSpace;
+ usedPercent = tusedPercent;
+}
+
+void RecMan::addEntry(ULONG startTime, char* name, char* fileName)
+{
+ Recording* rec = new Recording();
+ rec->setStartTime(startTime);
+ rec->setFileName(fileName);
+
+ // And now for the directory structure & prog name
+
+ printf("%lu %s %s\n", startTime, name, fileName);
+
+ char* c;
+ char* d;
+ stack<char*> dirNamesStack;
+ char* oneDirName;
+ bool gotProgName = false;
+ for(c = (name + strlen(name) - 1); c >= name; c--)
+ {
+ if ((*c == '~') || (c == name))
+ {
+ // Make d point to the start of the string (i.e. move on 1 from ~ if necessary)
+ if (c == name) d = name;
+ else d = c + 1;
+
+ if (!gotProgName)
+ {
+ printf("Got prog name '%s'\n", d);
+ rec->setProgName(d); // will copy from d to end of string
+ *c = '\0';
+ gotProgName = true;
+ }
+ else
+ {
+ // get the dir
+ oneDirName = new char[strlen(d) + 1];
+ strcpy(oneDirName, d);
+ dirNamesStack.push(oneDirName);
+ *c = '\0';
+ }
+ }
+ }
+
+ Directory* targetDirectory = rootDir;
+ Directory* getDir;
+
+ while(!dirNamesStack.empty())
+ {
+ oneDirName = dirNamesStack.top();
+ if (!oneDirName) break;
+
+ getDir = targetDirectory->getDirByName(oneDirName);
+ if (getDir)
+ {
+ targetDirectory = getDir;
+ }
+ else
+ {
+ printf("making new dir '%s'\n", oneDirName);
+ getDir = new Directory(oneDirName); // Make a new directory
+ getDir->parent = targetDirectory;
+ targetDirectory->dirList.push_back(getDir); // Put the new directory in the tree
+ targetDirectory = getDir; // Make the new dir the target
+ }
+
+ dirNamesStack.pop();
+ delete[] oneDirName;
+ }
+
+ targetDirectory->recList.push_back(rec);
+
+ // Sort it all.
+ rootDir->sort();
+}
+
+ULONG RecMan::getTotalSpace()
+{
+ return totalSpace;
+}
+
+ULONG RecMan::getFreeSpace()
+{
+ return freeSpace;
+}
+
+ULONG RecMan::getUsedPercent()
+{
+ return usedPercent;
+}
+
+int RecMan::deleteRecording(Recording* rec)
+{
+ int success = 0;
+
+ for(RecordingList::iterator i = currentDir->recList.begin(); i != currentDir->recList.end(); i++)
+ {
+ if (*i == rec)
+ {
+ success = VDR::getInstance()->deleteRecording(rec->getFileName());
+ if (success == 1)
+ {
+ currentDir->recList.erase(i);
+ delete rec;
+ }
+ break;
+ }
+ }
+
+ return success;
+}
+
+bool RecMan::isSubDir()
+{
+ return (currentDir != rootDir);
+}
+
+bool RecMan::down(Directory* downDir)
+{
+ // Check dir is in currentDir
+ for(DirectoryList::iterator i = currentDir->dirList.begin(); i != currentDir->dirList.end(); i++)
+ {
+ if (*i == downDir)
+ {
+ currentDir = downDir;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool RecMan::up()
+{
+ if (!isSubDir()) return false;
+
+ Directory* oldDir = currentDir;
+ currentDir = currentDir->parent;
+
+ if (oldDir->getNumRecordings() == 0)
+ {
+ // delete the olddir
+ Directory* tempdir;
+ for (DirectoryList::iterator i = currentDir->dirList.begin(); i != currentDir->dirList.end(); i++)
+ {
+ tempdir = *i;
+ if (tempdir == oldDir)
+ {
+ currentDir->dirList.erase(i);
+ delete tempdir;
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+char* RecMan::getCurDirName()
+{
+ return currentDir->name;
+}
+
+DirectoryList* RecMan::getDirectories()
+{
+ return ¤tDir->dirList;
+}
+
+RecordingList* RecMan::getRecordings()
+{
+ return ¤tDir->recList;
+}
--- /dev/null
+/*
+ Copyright 2006 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with VOMP; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef RECMAN_H
+#define RECMAN_H
+
+#include <stack>
+
+#include "directory.h"
+#include "recording.h"
+
+class RecMan
+{
+ public:
+ RecMan();
+ ~RecMan();
+
+ void setStats(ULONG totalSpace, ULONG freeSpace, ULONG usedPercent);
+ void addEntry(ULONG startTime, char* name, char* filename); // modifies name
+ int deleteRecording(Recording* rec);
+
+ // State functions
+ bool isSubDir();
+ bool up();
+ bool down(Directory* downDir);
+ char* getCurDirName();
+ DirectoryList* getDirectories();
+ RecordingList* getRecordings();
+
+ ULONG getTotalSpace();
+ ULONG getFreeSpace();
+ ULONG getUsedPercent();
+
+ private:
+ ULONG totalSpace;
+ ULONG freeSpace;
+ ULONG usedPercent;
+
+ Directory* rootDir;
+ Directory* currentDir;
+};
+
+#endif
Recording::Recording()
{
start = 0;
- dirName = NULL;
progName = NULL;
fileName = NULL;
-
index = -1;
}
Recording::~Recording()
{
- if (dirName) delete[] dirName;
- if (progName) delete[] progName;
- if (fileName) delete[] fileName;
+ if (progName) { free(progName); progName = NULL; }
+ if (fileName) { free(fileName); fileName = NULL; }
index = -1; // just in case
}
-int Recording::isInDir()
+ULONG Recording::getStartTime() const
{
-// if (strstr(name, "~")) return 1;
-// else return 0;
- return (dirName != NULL);
+ return start;
}
-char* Recording::getDirName()
+char* Recording::getProgName() const
{
-/* char* sub = strstr(name, "~");
- if (!sub) return NULL;
+ return progName;
+}
- char* dirName = new char[sub - name + 1];
- memcpy(dirName, name, sub - name);
- dirName[sub - name] = '\0';
- return dirName;
-*/
- return dirName;
+char* Recording::getFileName() const
+{
+ return fileName;
}
-char* Recording::getProgName() const
+void Recording::setStartTime(ULONG tstartTime)
{
- return progName;
+ start = tstartTime;
}
-void Recording::setName(char* name)
+void Recording::setProgName(char* tProgName)
{
- char* sub = strstr(name, "~");
+ if (progName) free(progName);
- if (sub) // Its in a dir
+ if (asprintf(&progName, tProgName) == -1)
{
- dirName = new char[sub - name + 1];
- memcpy(dirName, name, sub - name);
- dirName[sub - name] = '\0';
-
- sub++;
- int sublen = strlen(sub);
- progName = new char[sublen + 1];
- memcpy(progName, sub, strlen(sub));
- progName[sublen] = '\0';
+ free(progName);
+ progName = NULL;
}
- else
+}
+
+void Recording::setFileName(char* tFileName)
+{
+ if (fileName) free(fileName);
+
+ if (asprintf(&fileName, tFileName) == -1)
{
- int len = strlen(name);
- progName = new char[len + 1];
- memcpy(progName, name, len);
- progName[len] = '\0';
+ free(fileName);
+ fileName = NULL;
}
}
#define RECORDING_H
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include "defines.h"
class Recording
{
Recording();
~Recording();
- void setName(char* name);
+ void setStartTime(ULONG startTime);
+ void setProgName(char* progName);
+ void setFileName(char* fileName);
- int isInDir();
- char* getDirName();
+ ULONG getStartTime() const;
char* getProgName() const;
-
- unsigned long start;
- char* fileName;
+ char* getFileName() const;
int index;
private:
- char* dirName;
+ ULONG start;
char* progName;
+ char* fileName;
+
};
#endif
return 1;
}
-Directory* VDR::getRecordingsList()
+bool VDR::getRecordingsList(RecMan* recman)
{
UCHAR buffer[8];
{
disconnect();
MUTEX_UNLOCK(&mutex);
- return NULL;
+ return false;
}
// reply
if (!getPacket())
{
MUTEX_UNLOCK(&mutex);
- return NULL;
+ return false;
}
- Directory* recDir = new Directory();
- recDir->setName("/");
- recDir->isRoot = 1;
-
- Directory::totalSpace = extractULONG();
- Directory::freeSpace = extractULONG();
- Directory::usedPercent = extractULONG();
+ recman->setStats(extractULONG(), extractULONG(), extractULONG());
- char* string;
+ ULONG start;
+ char* name;
+ char* fileName;
while (packetPos < packetLength)
{
- Recording* rec = new Recording();
-
- rec->start = extractULONG();
-
- string = extractString();
- rec->setName(string);
- delete[] string;
-
- rec->fileName = extractString();
-
- if(rec->isInDir())
- {
- char* dirName = rec->getDirName();
-
- Directory* d = recDir->getDirByName(dirName);
- if (!d)
- {
- d = new Directory();
- d->setName(dirName);
-// Log::getInstance()->log("VDR", Log::DEBUG, "Added a new directory = %s", d->name);
- recDir->dirList.push_back(d);
- }
+ start = extractULONG();
+ name = extractString();
+ fileName = extractString();
- d->recList.push_back(rec);
- }
- else
- {
- recDir->recList.push_back(rec);
- }
+ recman->addEntry(start, name, fileName);
-// Log::getInstance()->log("VDR", Log::DEBUG, "%s", rec->fileName);
+ delete[] name;
+ delete[] fileName;
}
freePacket();
MUTEX_UNLOCK(&mutex);
- // Sort the directory order
- sort(recDir->dirList.begin(), recDir->dirList.end(), DirectorySorter());
-
- // Sort all the sub lists
- Directory* sortDir;
- DirectoryList::iterator i;
- for (i = recDir->dirList.begin(); i != recDir->dirList.end(); i++)
- {
- sortDir = *i;
- sort(sortDir->recList.begin(), sortDir->recList.end(), RecordingSorter());
- }
-
- // Sort the root level list
- sort(recDir->recList.begin(), recDir->recList.end(), RecordingSorter());
-
- return recDir;
+ return true;
}
int VDR::deleteRecording(char* fileName)
return toReturn;
}
-ULLONG VDR::streamRecording(Recording* rec)
+ULLONG VDR::streamRecording(char* fileName)
{
- unsigned long totalLength = 8 + strlen(rec->fileName) + 1;
+ unsigned long totalLength = 8 + strlen(fileName) + 1;
UCHAR* buffer = new UCHAR[totalLength];
*(unsigned long*)&buffer[0] = htonl(totalLength - 4);
*(unsigned long*)&buffer[4] = htonl(VDR_STREAMRECORDING);
- strcpy((char*)&buffer[8], rec->fileName);
+ strcpy((char*)&buffer[8], fileName);
MUTEX_LOCK(&mutex);
if (!connected) { MUTEX_UNLOCK(&mutex); return 0; }
#include "log.h"
#include "dsock.h"
#include "tcp.h"
-#include "directory.h"
-#include "recording.h"
#include "channel.h"
#include "event.h"
#include "rectimer.h"
+#include "recman.h"
using namespace std;
}
};
-struct RecordingSorter
-{
- bool operator() (const Recording* a, const Recording* b)
- {
- int c = strcmp(b->getProgName(), a->getProgName());
- if (c > 0) return true;
- if (c < 0) return false;
-
- return a->start < b->start;
- }
-};
-
-struct DirectorySorter
-{
- bool operator() (const Directory* a, const Directory* b)
- {
- int c = strcmp(b->name, a->name);
- if (c > 0) return true;
- return false;
- }
-};
class VDR
{
int doLogin();
- Directory* getRecordingsList();
+ bool getRecordingsList(RecMan* recman);
char* getRecordingSummary(char* fileName);
int deleteRecording(char* fileName);
- ULLONG streamRecording(Recording* rec);
+ ULLONG streamRecording(char* fileName);
ULLONG rescanRecording();
ULLONG positionFromFrameNumber(ULONG frameNumber);
- ULONG frameNumberFromPosition(ULLONG position);
+ ULONG frameNumberFromPosition(ULLONG position);
ChannelList* getChannelsList(ULONG type);
int streamChannel(ULONG number);
const static ULONG VDR_GETTIMERS = 14;
const static ULONG VDR_SETTIMER = 15;
const static ULONG VDR_POSFROMFRAME = 16;
- const static ULONG VDR_FRAMEFROMPOS = 17;
+ const static ULONG VDR_FRAMEFROMPOS = 17;
int getPacket();
void freePacket();
#include "vrecordinglist.h"
-VRecordingList::VRecordingList(VRecordingList* tparent, Directory* tdir)
+VRecordingList::VRecordingList()
{
- myParent = tparent;
viewman = ViewMan::getInstance();
- recDir = tdir;
+ recman = NULL;
+ loading = true;
create(570, 420);
if (Video::getInstance()->getFormat() == Video::PAL)
VRecordingList::~VRecordingList()
{
- if (myParent)
- {
- // if this is a sub, there can only be recordings. if there are none left, get this dir deleted by parent
- if (recDir->getNumRecordings() == 0) myParent->zeroCheck();
- // recDir is now deleted if it was empty
- }
- else
- {
- // only delete the list if this is not a sub dir window
- delete recDir;
- }
-}
-
-void VRecordingList::zeroCheck()
-{
- // go through to delete 1 empty dir if necessary (there will only ever be 1)
- Directory* dir;
- DirectoryList::iterator i;
- for (i = recDir->dirList.begin(); i != recDir->dirList.end(); i++)
- {
- dir = *i;
- if (dir->getNumRecordings() == 0)
- {
- delete dir;
- recDir->dirList.erase(i);
- break;
- }
- }
- drawData();
- viewman->updateView(this);
+ delete recman;
}
-void VRecordingList::drawData()
+void VRecordingList::drawData(bool doIndexPop)
{
int saveIndex = sl.getCurrentOption();
int saveTop = sl.getTopOption();
char tempB[300]; // FIXME
struct tm* btime;
- Directory* dir;
+ Directory* currentSubDir;
DirectoryList::iterator i;
- for (i = recDir->dirList.begin(); i != recDir->dirList.end(); i++)
+ DirectoryList* dirList = recman->getDirectories();
+ for (i = dirList->begin(); i != dirList->end(); i++)
{
- dir = *i;
- SNPRINTF(tempA, 299, tr("<dir> %lu\t%s"), dir->getNumRecordings(), dir->name);
- dir->index = sl.addOption(tempA, first);
+ currentSubDir = *i;
+ SNPRINTF(tempA, 299, tr("<dir> %lu\t%s"), currentSubDir->getNumRecordings(), currentSubDir->name);
+ currentSubDir->index = sl.addOption(tempA, first);
first = 0;
}
// FIXME convert the whole program to time_t's
- Recording* rec;
- for (UINT j = 0; j < recDir->recList.size(); j++)
+ Recording* currentRec;
+ RecordingList::iterator j;
+ RecordingList* recList = recman->getRecordings();
+ for (j = recList->begin(); j != recList->end(); j++)
{
- rec = recDir->recList[j];
- btime = localtime((time_t*)&rec->start);
+ currentRec = *j;
+ time_t recStartTime = (time_t)currentRec->getStartTime();
+ btime = localtime(&recStartTime);
#ifndef _MSC_VER
strftime(tempA, 299, "%0d/%0m %0H:%0M ", btime);
#else
strftime(tempA, 299, "%d/%m %H:%M ", btime);
#endif
- sprintf(tempB, "%s\t%s", tempA, rec->getProgName());
- rec->index = sl.addOption(tempB, first);
+ sprintf(tempB, "%s\t%s", tempA, currentRec->getProgName());
+ currentRec->index = sl.addOption(tempB, first);
first = 0;
}
- sl.hintSetCurrent(saveIndex);
- sl.hintSetTop(saveTop);
+ if (doIndexPop)
+ {
+ sl.hintSetCurrent(slIndexStack.top());
+ slIndexStack.pop();
+ }
+ else
+ {
+ sl.hintSetCurrent(saveIndex);
+ sl.hintSetTop(saveTop);
+ }
sl.draw();
doShowingBar();
}
-void VRecordingList::draw()
+void VRecordingList::draw(bool doIndexPop)
{
- char title[300];
- if (myParent)
- {
- SNPRINTF(title, 299, tr("Recordings - %s"), recDir->name);
- setTitleText(title);
- }
- else
+ if (!loading)
{
- setTitleText(tr("Recordings"));
+ if (recman->isSubDir())
+ {
+ char title[300];
+ SNPRINTF(title, 299, tr("Recordings - %s"), recman->getCurDirName());
+ setTitleText(title);
+ }
+ else
+ {
+ setTitleText(tr("Recordings"));
+ }
}
View::draw();
- char freeSpace[50];
- int gigFree = Directory::freeSpace / 1024;
- SNPRINTF(freeSpace, 49, tr("%lu%% used, %iGB free"), Directory::usedPercent, gigFree);
- drawTextRJ(freeSpace, 560, 5, Colour::LIGHTTEXT);
+ if (loading)
+ {
+ drawText(tr("Loading..."), 240, 180, Colour::LIGHTTEXT);
+ }
+ else
+ {
+ char freeSpace[50];
+ int gigFree = recman->getFreeSpace() / 1024;
+ SNPRINTF(freeSpace, 49, tr("%lu%% used, %iGB free"), recman->getUsedPercent(), gigFree);
+ drawTextRJ(freeSpace, 560, 5, Colour::LIGHTTEXT);
- // Symbols
+ // Symbols
- WSymbol w;
- w.setSurface(surface);
+ WSymbol w;
+ w.setSurface(surface);
- w.nextSymbol = WSymbol::UP;
- w.setSurfaceOffset(20, 385);
- w.draw();
+ w.nextSymbol = WSymbol::UP;
+ w.setSurfaceOffset(20, 385);
+ w.draw();
- w.nextSymbol = WSymbol::DOWN;
- w.setSurfaceOffset(50, 385);
- w.draw();
+ w.nextSymbol = WSymbol::DOWN;
+ w.setSurfaceOffset(50, 385);
+ w.draw();
- w.nextSymbol = WSymbol::SKIPBACK;
- w.setSurfaceOffset(85, 385);
- w.draw();
+ w.nextSymbol = WSymbol::SKIPBACK;
+ w.setSurfaceOffset(85, 385);
+ w.draw();
- w.nextSymbol = WSymbol::SKIPFORWARD;
- w.setSurfaceOffset(115, 385);
- w.draw();
+ w.nextSymbol = WSymbol::SKIPFORWARD;
+ w.setSurfaceOffset(115, 385);
+ w.draw();
- w.nextSymbol = WSymbol::PLAY;
- w.setSurfaceOffset(150, 385);
- w.draw();
+ w.nextSymbol = WSymbol::PLAY;
+ w.setSurfaceOffset(150, 385);
+ w.draw();
- drawTextRJ(tr("[ok] = menu"), 560, 385, Colour::LIGHTTEXT);
+ drawTextRJ(tr("[ok] = menu"), 560, 385, Colour::LIGHTTEXT);
- // All static stuff done
+ // All static stuff done
- drawData();
+ drawData(doIndexPop);
+ }
}
void VRecordingList::doShowingBar()
void VRecordingList::doDeleteSelected()
{
- Log::getInstance()->log("VRecordingList", Log::DEBUG, "Parent = %p, isRoot = %i", myParent, recDir->isRoot);
Recording* toDelete = getCurrentOptionRecording();
if (toDelete)
{
- Log::getInstance()->log("VRecordingList", Log::DEBUG, "FOUND: %i %s %s", toDelete->index, toDelete->getProgName(), toDelete->fileName);
+ Log::getInstance()->log("VRecordingList", Log::DEBUG, "FOUND: %i %s %s", toDelete->index, toDelete->getProgName(), toDelete->getFileName());
- VDR* vdr = VDR::getInstance();
- int success = vdr->deleteRecording(toDelete->fileName);
- if (!vdr->isConnected())
+ int success = recman->deleteRecording(toDelete);
+ if (!VDR::getInstance()->isConnected())
{
Command::getInstance()->connectionLost();
+ return;
}
if (success != 1)
}
else
{
- delete toDelete;
-
- for(RecordingList::iterator i = recDir->recList.begin(); i != recDir->recList.end(); i++)
- {
- if (*i == toDelete)
- {
- recDir->recList.erase(i);
- break;
- }
- }
-
- drawData();
+ draw();
viewman->updateView(this);
-
- if (myParent) myParent->drawData(); // if this is not root get parent to redraw data
}
- Log::getInstance()->log("VRecordingList", Log::DEBUG, "Parent = %p, isRoot = %i", myParent, recDir->isRoot);
}
}
int VRecordingList::doResume()
{
Recording* toResume = getCurrentOptionRecording();
+
+ printf("%s\n", toResume->getFileName());
+
if (toResume)
{
- ULLONG position = VDR::getInstance()->getResumePoint(toResume->fileName);
+ ULLONG position = VDR::getInstance()->getResumePoint(toResume->getFileName());
VVideoRec* vidrec = new VVideoRec(toResume);
vidrec->draw();
vidrec->go(position);
return 1;
}
- // should not get to here
+
+// should not get to here
return 0;
}
Recording* VRecordingList::getCurrentOptionRecording()
{
- Recording* current;
- for (UINT i = 0; i < recDir->recList.size(); i++)
+ Recording* currentRec;
+ RecordingList::iterator j;
+ RecordingList* recList = recman->getRecordings();
+ for (j = recList->begin(); j != recList->end(); j++)
{
- current = recDir->recList[i];
- if (current->index == sl.getCurrentOption()) return current;
+ currentRec = *j;
+ if (currentRec->index == sl.getCurrentOption()) return currentRec;
}
+
return NULL;
}
if (sl.getNumOptions() == 0) return 2;
// Check to see if it is a sub directory
- Directory* curDir;
- for(UINT i = 0; i < recDir->dirList.size(); i++)
+ Directory* currentSubDir;
+ DirectoryList::iterator i;
+ DirectoryList* dirList = recman->getDirectories();
+ for (i = dirList->begin(); i != dirList->end(); i++)
{
- curDir = recDir->dirList[i];
- if (curDir->index == sl.getCurrentOption())
+ currentSubDir = *i;
+ if (currentSubDir->index == sl.getCurrentOption())
{
- VRecordingList* sub = new VRecordingList(this, curDir);
- sub->draw();
- viewman->add(sub);
- viewman->updateView(sub);
+ if (recman->down(currentSubDir))
+ {
+ slIndexStack.push(sl.getCurrentOption());
+ sl.clear();
+ draw();
+ viewman->updateView(this);
+ }
return 2;
}
}
Recording* current = getCurrentOptionRecording();
if (current)
{
- Log::getInstance()->log("VRecordingList", Log::DEBUG, "Found the option you pointed at. %s %s", current->getProgName(), current->fileName);
+ Log::getInstance()->log("VRecordingList", Log::DEBUG, "Found the option you pointed at. %s %s", current->getProgName(), current->getFileName());
VRecordingMenu* v = new VRecordingMenu();
v->setParent(this);
}
case Remote::BACK:
{
- return 4;
+ if (recman->isSubDir())
+ {
+ recman->up();
+ sl.clear();
+ draw(true);
+ viewman->updateView(this);
+ return 2;
+ }
+ else
+ {
+ return 4;
+ }
}
case Remote::PLAY:
{
// stop command getting to any more views
return 1;
}
+
+bool VRecordingList::load()
+{
+ recman = new RecMan();
+ bool success = VDR::getInstance()->getRecordingsList(recman);
+ if (success)
+ {
+ loading = false;
+ draw();
+ viewman->updateView(this);
+ }
+
+ return success;
+}
+
#include <string.h>
#include <time.h>
#include <vector>
+#include <stack>
#include "view.h"
+#include "recman.h"
#include "directory.h"
#include "recording.h"
#include "wselectlist.h"
class VRecordingList : public View
{
public:
- VRecordingList(VRecordingList* parent, Directory* dir);
+ VRecordingList();
~VRecordingList();
int handleCommand(int command);
void processMessage(Message* m);
- void draw();
-
- void drawData();
- void zeroCheck();
+ void draw(bool doIndexPop = false);
+ bool load();
+ void drawData(bool doIndexPop = false);
private:
- VRecordingList* myParent;
- Directory* recDir;
ViewMan* viewman;
+ bool loading;
+ RecMan* recman;
+ Directory* dir;
+
WSelectList sl;
void doShowingBar();
int doPlay();
int doResume();
Recording* getCurrentOptionRecording();
+
+ stack<int> slIndexStack;
};
#endif
if (sl.getCurrentOption() == 2)
{
- char* summary = VDR::getInstance()->getRecordingSummary(rec->fileName);
+ char* summary = VDR::getInstance()->getRecordingSummary(rec->getFileName());
if (!summary && !VDR::getInstance()->isConnected())
{
Command::getInstance()->connectionLost();
void VVideoRec::go(ULLONG startPosition)
{
- ULLONG recLength = vdr->streamRecording(myRec);
+ ULLONG recLength = vdr->streamRecording(myRec->getFileName());
if (recLength)
{
doBar(0);
void VWelcome::doRecordingsList()
{
- VInfo* viewWait = new VInfo();
- viewWait->create(460, 190);
- if (Video::getInstance()->getFormat() == Video::PAL)
- {
- viewWait->setScreenPos(140, 170);
- }
- else
- {
- viewWait->setScreenPos(130, 140);
- }
- viewWait->setOneLiner(tr("Downloading recordings list"));
- viewWait->draw();
- viewman->add(viewWait);
- viewman->updateView(viewWait);
+ VRecordingList* vrec = new VRecordingList();
+ vrec->draw();
+ viewman->add(vrec);
+ viewman->updateView(vrec);
- VDR* vdr = VDR::getInstance();
- Directory* recDir = vdr->getRecordingsList();
-
- if (recDir)
- {
- VRecordingList* vrec = new VRecordingList(NULL, recDir);
- vrec->draw();
-
- viewman->add(vrec);
- viewman->updateView(vrec);
- }
- else
+ if (!vrec->load())
{
Command::getInstance()->connectionLost();
}
-
- viewman->removeView(viewWait);
}
void VWelcome::doTimersList()
#include "wjpeg.h"
#include "viewman.h"
#include "vdr.h"
-#include "directory.h"
#include "vchannellist.h"
#include "vrecordinglist.h"
#include "vtimerlist.h"