// Open a config file for the given MAC
+#ifndef VOMPSTANDALONE
const char* configDir = cPlugin::ConfigDirectory();
+#else
+ const char* configDir = ".";
+#endif
// char* configDir = "/opt/dvb/vdr-config-1.3/plugins";
if (!configDir)
{
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
+#ifndef VOMPSTANDALONE
#include <vdr/plugin.h>
+#endif
#include "defines.h"
#include "log.h"
*/
#include "media.h"
-//#include "tools.h"
#include <sys/stat.h>
#include <sys/types.h>
+#include <dirent.h>
+#include <iostream>
+
//#define NUMTYPES (sizeof(mediatypes)/sizeof(mtype))
#define NUMTYPES 6
+//helper from vdr tools.c
+bool endswith(const char *s, const char *p)
+{
+ const char *se = s + strlen(s) - 1;
+ const char *pe = p + strlen(p) - 1;
+ while (pe >= p) {
+ if (*pe-- != *se-- || (se < s && pe >= p))
+ return false;
+ }
+ return true;
+}
+
+
MediaList * MediaList::readList(Config * cfg,const char * dirname, int type) {
MediaList *rt=NULL;
if (dirname == NULL) {
if (dn != NULL) {
if (rt == NULL) rt=new MediaList();
Media *m=new Media(MEDIA_TYPE_DIR,dn,0);
- rt->Add(m);
+ rt->push_back(m);
Log::getInstance()->log("Media",Log::DEBUG,"added base dir %s",dn);
}
}
if (dirname == NULL) dirname="/";
rt=new MediaList();
//open the directory and read out the entries
- cReadDir d(dirname);
+ DIR *d=opendir(dirname);
struct dirent *e;
- while ((e=d.Next()) != NULL) {
+ union { // according to "The GNU C Library Reference Manual"
+ struct dirent d;
+ char b[offsetof(struct dirent, d_name) + NAME_MAX + 1];
+ } u;
+
+ while (d != NULL && (readdir_r(d,&u.d,&e) == 0) && e != NULL) {
{
const char * fname=e->d_name;
if ( fname == NULL) continue;
//only consider entries we accept by type here
if (mtype & type) {
Media * m =new Media(mtype,fname,(int)(st.st_mtime));
- rt->Add(m);
+ rt->push_back(m);
Log::getInstance()->log("Media",Log::DEBUG,"added entry %s, type=%d",fname,mtype);
}
}
}
- //test
- //Media *m=new Media(MEDIA_TYPE_DIR,"testMedia1",0);
- //rt->Add(m);
+ if (d != NULL) closedir(d);
return rt;
}
+MediaList::~MediaList() {
+ MediaList::iterator it=this->begin();
+ while (it < this->end()) {
+ delete *it;
+ it++;
+ }
+}
#include <endian.h>
#include <unistd.h> // sleep
+#include <vector>
-#include <vdr/tools.h>
-
+using namespace std;
//#include "defines.h"
//#include "tcp.h"
//#include "mvpreceiver.h"
#define MEDIA_TYPE_ALL (1+2+4+8)
-class Media : public cListObject
+class Media
{
public:
/**
};
-class MediaList : public cList<Media> {
+class MediaList : public vector<Media*> {
public:
static MediaList *readList(Config *cfg,const char * dirname,int type=MEDIA_TYPE_ALL);
+ ~MediaList();
};
#endif
MVPClient::MVPClient(Config* cfgBase, char* tconfigDirExtra, int tsocket)
: tcp(tsocket)
{
+#ifndef VOMPSTANDALONE
lp = NULL;
rp = NULL;
- imageFile = 0;
recordingManager = NULL;
+#endif
+ imageFile = 0;
log = Log::getInstance();
loggedIn = false;
configDirExtra = tconfigDirExtra;
MVPClient::~MVPClient()
{
log->log("Client", Log::DEBUG, "MVP client destructor");
+#ifndef VOMPSTANDALONE
if (lp)
{
delete lp;
rp = NULL;
recordingManager = NULL;
}
-
+#endif
if (loggedIn) cleanConfig();
decClients();
}
#endif
}
+#ifndef VOMPSTANDALONE
cChannel* MVPClient::channelFromNumber(ULONG channelNumber)
{
cChannel* channel = NULL;
(char*)rp->getCurrentRecording()->FileName(),
rp->frameNumberFromPosition(rp->getLastPosition()) );
}
+#endif
void MVPClient::sendULONG(ULONG ul)
{
case 1:
result = processLogin(data, extraDataLength);
break;
+#ifndef VOMPSTANDALONE
case 2:
result = processGetRecordingsList(data, extraDataLength);
break;
case 10:
result = processGetChannelSchedule(data, extraDataLength);
break;
+#endif
case 11:
result = processConfigSave(data, extraDataLength);
break;
case 12:
result = processConfigLoad(data, extraDataLength);
break;
+#ifndef VOMPSTANDALONE
case 13:
result = processReScanRecording(data, extraDataLength); // FIXME obselete
break;
case 23:
result = processDeleteTimer(data, extraDataLength);
break;
+#endif
case 30:
result = processGetMediaList(data, extraDataLength);
break;
// Open the config
+#ifndef VOMPSTANDALONE
const char* configDir = cPlugin::ConfigDirectory(configDirExtra);
+#else
+ const char* configDir = ".";
+#endif
if (!configDir)
{
log->log("Client", Log::DEBUG, "No config dir!");
return 1;
}
+#ifndef VOMPSTANDALONE
int MVPClient::processGetRecordingsList(UCHAR* data, int length)
{
UCHAR* sendBuffer = new UCHAR[50000]; // hope this is enough
return 1;
}
+#endif //VOMPSTANDALONE
+
int MVPClient::processConfigSave(UCHAR* buffer, int length)
{
char* section = (char*)buffer;
{
log->log("Client", Log::DEBUG, "Clean config");
+#ifndef VOMPSTANDALONE
cRecordings Recordings;
Recordings.Load();
}
delete[] resumes;
+#endif
}
pending is a bool, 0 for would not be trying to record this right now, 1 for would/is trying to record this right now
*/
+#ifndef VOMPSTANDALONE
int MVPClient::processGetTimers(UCHAR* buffer, int length)
{
return 1;
}
+#endif //VOMPSTANDALONE
+
void MVPClient::incClients()
{
pthread_mutex_lock(&threadClientMutex);
return nrClients;
}
+#ifndef VOMPSTANDALONE
+
int MVPClient::processGetRecInfo(UCHAR* data, int length)
{
// data is a pointer to the fileName string
return 1;
}
+#endif //VOMPSTANDALONE
+
/**
* media List Request:
*(ULONG*)&sendBuffer[count] = htonl(0);
count += 4;
//numentries
- *(ULONG*)&sendBuffer[count] = htonl(ml->Count());
+ *(ULONG*)&sendBuffer[count] = htonl(ml->size());
count += 4;
- for (int nm=0;nm<ml->Count() && count < (MLISTBUF-1000);nm++) {
- Media *m=ml->Get(nm);
+ for (MediaList::iterator nm=ml->begin();nm<ml->end() && count < (MLISTBUF-1000);nm++) {
+ Media *m=*nm;
log->log("Client", Log::DEBUG, "found media entry %s, type=%d",m->getFilename(),m->getType());
*(ULONG*)&sendBuffer[count] = htonl(m->getType());
count += 4;
/**
* get image Request:
- * 4 length
- * 4 VDR_GETIMAGE
* 4 flags (currently unused)
* 4 x size
* 4 y size
imageFile=NULL;
}
char * filename=NULL;
- if (length > 4) {
+ if (length > 12) {
//we have a dirname provided
- filename=(char *)&data[4];
+ filename=(char *)&data[12];
log->log("Client", Log::DEBUG, "getPicture %s", filename);
}
else {
return 1;
}
+#ifndef VOMPSTANDALONE
+
int MVPClient::processDeleteTimer(UCHAR* buffer, int length)
{
log->log("Client", Log::DEBUG, "Delete timer called");
}
}
+#endif
#include <unistd.h> // sleep
+#ifndef VOMPSTANDALONE
#include <vdr/recording.h>
#include <vdr/channels.h>
#include <vdr/videodir.h>
#include <vdr/plugin.h>
#include <vdr/timers.h>
#include <vdr/menu.h>
+#include "recplayer.h"
+#include "mvpreceiver.h"
+#endif
#include "defines.h"
#include "tcp.h"
-#include "mvpreceiver.h"
-#include "recplayer.h"
#include "config.h"
#include "media.h"
TCP tcp;
Config config;
Config* baseConfig;
- MVPReceiver* lp;
bool loggedIn;
char* configDirExtra;
FILE* imageFile;
-
+#ifndef VOMPSTANDALONE
+ MVPReceiver* lp;
cRecordings* recordingManager;
RecPlayer* rp;
+#endif
Log* log;
int processLogin(UCHAR* buffer, int length);
+#ifndef VOMPSTANDALONE
int processGetRecordingsList(UCHAR* data, int length);
int processDeleteRecording(UCHAR* data, int length);
int processMoveRecording(UCHAR* data, int length);
int processStopStreaming(UCHAR* data, int length);
int processStartStreamingRecording(UCHAR* data, int length);
int processGetChannelSchedule(UCHAR* data, int length);
- int processConfigSave(UCHAR* data, int length);
- int processConfigLoad(UCHAR* data, int length);
int processGetTimers(UCHAR* data, int length);
int processSetTimer(UCHAR* data, int length);
int processPositionFromFrameNumber(UCHAR* data, int length);
int processGetRecInfo(UCHAR* data, int length);
int processGetMarks(UCHAR* data, int length);
int processGetChannelPids(UCHAR* data, int length);
- int processGetMediaList(UCHAR* data, int length);
- int processGetPicture(UCHAR* data, int length);
- int processGetImageBlock(UCHAR* data, int length);
int processDeleteTimer(UCHAR* buffer, int length);
int processReScanRecording(UCHAR* data, int length); // FIXME obselete
+#endif
+ int processConfigSave(UCHAR* data, int length);
+ int processConfigLoad(UCHAR* data, int length);
+ int processGetMediaList(UCHAR* data, int length);
+ int processGetPicture(UCHAR* data, int length);
+ int processGetImageBlock(UCHAR* data, int length);
void incClients();
void decClients();
-
+#ifndef VOMPSTANDALONE
cChannel* channelFromNumber(ULONG channelNumber);
void writeResumeData();
+#endif
void cleanConfig();
void sendULONG(ULONG ul);
*/
#include "mvpserver.h"
+#ifdef VOMPSTANDALONE
+#include <iostream>
+#endif
extern pthread_mutex_t threadClientMutex;
configDirExtra = tconfigDirExtra;
// Start config
+#ifndef VOMPSTANDALONE
const char* configDir = cPlugin::ConfigDirectory(configDirExtra);
+#else
+ const char* configDir = ".";
+#define dsyslog(x) std::cout << x << std::endl;
+#endif
if (!configDir)
{
dsyslog("VOMP: Could not get config dir from VDR");
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
+#ifndef VOMPSTANDALONE
#include <vdr/plugin.h>
+#endif
#include "defines.h"
#include "log.h"
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
+#ifndef VOMPSTANDALONE
#include <vdr/plugin.h>
+#endif
#include "defines.h"
#include "log.h"
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef VOMPSTANDALONE
#include <vdr/plugin.h>
+#endif
+#include <iostream>
#include <getopt.h>
#include "mvpserver.h"
static const char *VERSION = "0.2.7";
static const char *DESCRIPTION = "VDR on MVP plugin by Chris Tallon";
+#ifndef VOMPSTANDALONE
class cPluginVompserver : public cPlugin
{
public:
VDRPLUGINCREATOR(cPluginVompserver); // Don't touch this!
+#else //VOMPSTANDALONE
+
+int main(int argc, char **argv) {
+ char *cdir=".";
+ if (argc > 1) {
+ cdir=argv[1];
+ }
+ std::cout << "Vompserver starting Version " << VERSION << " " << DESCRIPTION << std::endl;
+ MVPServer server;
+ if ( server.run(cdir) != 1) {
+ std::cerr << "unable to start vompserver" << std::endl;
+ return 1;
+ }
+ while (1) sleep(1);
+ return 0;
+}
+
+#endif //VOMPSTANDALONE