// viewman->redrawAll();
/*
+ handleCommand(Remote::DOWN);
+ handleCommand(Remote::DOWN);
+ handleCommand(Remote::OK);
handleCommand(Remote::DOWN);
handleCommand(Remote::DOWN);
handleCommand(Remote::DOWN);
handleCommand(Remote::OK);
-*/
+ handleCommand(Remote::OK);
+ handleCommand(Remote::UP);
+ handleCommand(Remote::OK);
+ handleCommand(Remote::DF_LEFT);
+ handleCommand(Remote::OK);
+ handleCommand(Remote::BACK);
+ */
+
}
const static ULONG CHANNEL_UP = 15;
const static ULONG CHANNEL_DOWN = 16;
const static ULONG STREAM_END = 17;
+ const static ULONG CHILD_CLOSE = 18;
};
#endif
{
irun = 0;
vdr->cancelFindingServer();
- threadCancel();
+ threadStop();
}
void VConnect::draw()
show();
vdr->findServers(serverIPs);
- if (!irun) return;
+ if (!irun)
+ {
+ for(UINT k = 0; k < serverIPs.size(); k++) delete[] serverIPs[k];
+ serverIPs.clear();
+ return;
+ }
if (serverIPs.size() == 1)
{
vdr->setServerIP(serverIPs[selectedServer]);
// Clear the serverIPs vector
- for(UINT k = 0; k < serverIPs.size(); k++)
- {
- delete[] serverIPs[k];
- }
+ for(UINT k = 0; k < serverIPs.size(); k++) delete[] serverIPs[k];
serverIPs.clear();
setMainText("\n Connecting to VDR");
packetLength = 0;
packetPos = 0;
packet = NULL;
+ connected = false;
}
VDR::~VDR()
{
if (tcp) delete tcp;
tcp = new TCP();
- return tcp->connectTo(serverIP, 3024);
+ if (tcp->connectTo(serverIP, 3024))
+ {
+ connected = true;
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
}
void VDR::disconnect()
{
if (tcp) delete tcp;
tcp = NULL;
+ connected = false;
Log::getInstance()->log("VDR", Log::DEBUG, "Disconnect");
}
int VDR::doLogin()
{
+ if (!connected) return 0;
+
UCHAR buffer[8];
*(unsigned long*)&buffer[0] = htonl(4);
Directory* VDR::getRecordingsList()
{
+ if (!connected) return 0;
+
UCHAR buffer[8];
*(unsigned long*)&buffer[0] = htonl(4);
int VDR::deleteRecording(char* fileName)
{
+ if (!connected) return 0;
+
unsigned long totalLength = 8 + strlen(fileName) + 1;
UCHAR buffer[totalLength];
char* VDR::getRecordingSummary(char* fileName)
{
+ if (!connected) return 0;
+
unsigned long totalLength = 8 + strlen(fileName) + 1;
UCHAR buffer[totalLength];
ChannelList* VDR::getChannelsList(ULONG type)
{
+ if (!connected) return 0;
+
UCHAR buffer[8];
*(unsigned long*)&buffer[0] = htonl(4);
int VDR::streamChannel(ULONG number)
{
+ if (!connected) return 0;
+
UCHAR buffer[12];
*(unsigned long*)&buffer[0] = htonl(8);
int VDR::stopStreaming()
{
+ if (!connected) return 0;
+
UCHAR buffer[8];
*(unsigned long*)&buffer[0] = htonl(4);
UCHAR* VDR::getBlock(ULLONG position, UINT maxAmount, UINT* amountReceived)
{
+ if (!connected) return 0;
+
UCHAR buffer[20];
*(unsigned long*)&buffer[0] = htonl(16);
ULLONG VDR::streamRecording(Recording* rec)
{
+ if (!connected) return 0;
+
unsigned long totalLength = 8 + strlen(rec->fileName) + 1;
UCHAR buffer[totalLength];
ULLONG VDR::rescanRecording()
{
+ if (!connected) return 0;
+
unsigned long totalLength = 8;
UCHAR buffer[totalLength];
EventList* VDR::getChannelSchedule(ULONG number)
{
+ if (!connected) return 0;
+
UCHAR buffer[12];
*(unsigned long*)&buffer[0] = htonl(8);
ULLONG VDR::getResumePoint(char* fileName)
{
+ if (!connected) return 0;
+
char* resumeString = configLoad("ResumeData", fileName);
if (!resumeString) return 0;
int VDR::configSave(char* section, char* key, char* value)
{
+ if (!connected) return 0;
+
ULONG totalLength = 8 + strlen(section) + strlen(key) + strlen(value) + 3; // 8 for headers, 3 for nulls
UCHAR buffer[totalLength];
char* VDR::configLoad(char* section, char* key)
{
+ if (!connected) return 0;
+
ULONG totalLength = 8 + strlen(section) + strlen(key) + 2; // 8 for headers, 2 for nulls
UCHAR buffer[totalLength];
TCP* tcp;
int port;
char serverIP[16];
+ bool connected;
pthread_mutex_t mutex;
UCHAR* packet;
UCHAR titleBarOn;
UCHAR borderOn;
- char* titleText;
protected:
+ char* titleText;//FIXME move this back to private
Colour titleBarColour;
View* parent;
};
sl.setSurface(surface);
sl.setSurfaceOffset(10, 30 + 5);
sl.setDimensions(width - 20, height - 30 - 15 - 30);
-
- Log::getInstance()->log("VRecordingList", Log::DEBUG, "this=%p parent=%p\n", this, myParent);
}
VRecordingList::~VRecordingList()
{
+ // if this is a child window, inform the parent of our destruct
+ if (myParent)
+ {
+ Message* m = new Message();
+ m->to = myParent;
+ m->message = Message::CHILD_CLOSE;
+ ViewMan::getInstance()->postMessage(m);
+ }
+
// only delete the list if this is not a sub dir window
- if (recDir->isRoot) delete recDir;
+ if (recDir->isRoot)
+ {
+ delete recDir;
+ }
}
void VRecordingList::setDir(Directory* tdir)
Directory* dir;
DirectoryList::iterator i;
- // First go through to delete 1 empty dir if necessary
-
- for (i = recDir->dirList.begin(); i != recDir->dirList.end(); i++)
+ if (dataInvalid == 2) // special case, a child list has closed, check for 0 dir entries
{
- dir = *i;
- if (dir->getNumRecordings() == 0)
+
+ // First go through to delete 1 empty dir if necessary
+
+ for (i = recDir->dirList.begin(); i != recDir->dirList.end(); i++)
{
- delete dir;
- recDir->dirList.erase(i);
- break;
+ dir = *i;
+ if (dir->getNumRecordings() == 0)
+ {
+ delete dir;
+ recDir->dirList.erase(i);
+ break;
+ }
}
}
draw();
return;
}
+
+ if (m->message == Message::CHILD_CLOSE)
+ {
+ dataInvalid = 2;
+ draw();
+ show();
+ return;
+ }
}
void VRecordingList::doDeleteSelected()
}
if (myParent) // if this is not root send a message to parent to say redraw data
- {
+ { // FIXME not really necessary any more ?
Message* m1 = new Message();
m1->to = myParent;
m1->message = Message::REDRAW_DATA;
ViewMan::getInstance()->postMessage(m1);
}
-
show();
+
/*
Message* m2 = new Message();
m2->from = this;