mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
movieinfo: cleanup from unused code; reformat code; no binary changes
Origin commit data
------------------
Commit: 8b3b4ba4d1
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-08-11 (Thu, 11 Aug 2016)
Origin message was:
------------------
- movieinfo: cleanup from unused code; reformat code; no binary changes
This commit is contained in:
@@ -1,14 +1,10 @@
|
|||||||
/***************************************************************************
|
/*
|
||||||
Neutrino-GUI - DBoxII-Project
|
movieinfo - Neutrino-GUI
|
||||||
|
|
||||||
Homepage: http://dbox.cyberphoria.org/
|
Copyright (C) 2005 Günther <Günther@tuxbox.berlios.org>
|
||||||
|
|
||||||
Kommentar:
|
Copyright (C) 2009, 2012 Stefan Seyfried
|
||||||
|
Copyright (C) 2015 Sven Hoefer (svenhoefer)
|
||||||
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
|
|
||||||
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
|
|
||||||
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
|
|
||||||
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
|
|
||||||
|
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
||||||
@@ -26,20 +22,8 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
***********************************************************
|
*/
|
||||||
|
|
||||||
Module Name: movieinfo.cpp .
|
|
||||||
|
|
||||||
Description: Implementation of the CMovieInfo class
|
|
||||||
This class loads, saves and shows the movie Information from the any .xml File on HD
|
|
||||||
|
|
||||||
Date: Nov 2005
|
|
||||||
|
|
||||||
Author: Günther@tuxbox.berlios.org
|
|
||||||
|
|
||||||
Copyright(C) 2009, 2012 Stefan Seyfried
|
|
||||||
|
|
||||||
****************************************************************************/
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -56,30 +40,19 @@
|
|||||||
|
|
||||||
#include <neutrino.h>
|
#include <neutrino.h>
|
||||||
|
|
||||||
// #define XMLTREE_LIB
|
|
||||||
#ifdef XMLTREE_LIB
|
|
||||||
#include <xmltree/xmltree.h>
|
|
||||||
#include <xmltree/xmltok.h>
|
|
||||||
#endif
|
|
||||||
#define TRACE printf
|
#define TRACE printf
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
CMovieInfo::CMovieInfo()
|
CMovieInfo::CMovieInfo()
|
||||||
{
|
{
|
||||||
//TRACE("[mi] new\r\n");
|
//TRACE("[mi] new\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
CMovieInfo::~CMovieInfo()
|
CMovieInfo::~CMovieInfo()
|
||||||
{
|
{
|
||||||
//TRACE("[mi] del\r\n");
|
//TRACE("[mi] del\n");
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
bool CMovieInfo::convertTs2XmlName(std::string& filename)
|
bool CMovieInfo::convertTs2XmlName(std::string& filename)
|
||||||
{
|
{
|
||||||
size_t lastdot = filename.find_last_of(".");
|
size_t lastdot = filename.find_last_of(".");
|
||||||
@@ -91,9 +64,6 @@ bool CMovieInfo::convertTs2XmlName(std::string& filename)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
static void XML_ADD_TAG_STRING(std::string &_xml_text_, const char *_tag_name_, std::string _tag_content_)
|
static void XML_ADD_TAG_STRING(std::string &_xml_text_, const char *_tag_name_, std::string _tag_content_)
|
||||||
{
|
{
|
||||||
_xml_text_ += "\t\t<";
|
_xml_text_ += "\t\t<";
|
||||||
@@ -127,31 +97,9 @@ static void XML_ADD_TAG_LONG(std::string &_xml_text_, const char *_tag_name_, ui
|
|||||||
_xml_text_ += ">\n";
|
_xml_text_ += ">\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
std::string decodeXmlSpecialChars(std::string s);
|
|
||||||
|
|
||||||
static void XML_GET_DATA_STRING(XMLTreeNode *_node_, const char *_tag_, std::string &_string_dest_)
|
|
||||||
{
|
|
||||||
if(!strcmp(_node_->GetType(), _tag_) && _node_->GetData())
|
|
||||||
_string_dest_ = decodeXmlSpecialChars(_node_->GetData());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void XML_GET_DATA_INT(XMLTreeNode *_node_, const char *_tag_, int _int_dest_)
|
|
||||||
{
|
|
||||||
if(!strcmp(_node_->GetType(), _tag_) && _node_->GetData())
|
|
||||||
_int_dest_ = atoi(_node_->GetData());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void XML_GET_DATA_LONG(XMLTreeNode *_node_, const char *_tag_,long int _int_dest_)
|
|
||||||
{
|
|
||||||
if(!strcmp(_node_->GetType(), _tag_) && _node_->GetData());
|
|
||||||
sscanf(_node_->GetData(), "%llu", &_int_dest_);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool CMovieInfo::encodeMovieInfoXml(std::string * extMessage, MI_MOVIE_INFO * movie_info)
|
bool CMovieInfo::encodeMovieInfoXml(std::string * extMessage, MI_MOVIE_INFO * movie_info)
|
||||||
{
|
{
|
||||||
//TRACE("[mi]->encodeMovieInfoXml\r\n");
|
//TRACE("[mi]->encodeMovieInfoXml\n");
|
||||||
|
|
||||||
*extMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"
|
*extMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"
|
||||||
"<" MI_XML_TAG_NEUTRINO " commandversion=\"1\">\n"
|
"<" MI_XML_TAG_NEUTRINO " commandversion=\"1\">\n"
|
||||||
@@ -163,14 +111,14 @@ bool CMovieInfo::encodeMovieInfoXml(std::string * extMessage, MI_MOVIE_INFO * mo
|
|||||||
XML_ADD_TAG_LONG(*extMessage, MI_XML_TAG_ID, movie_info->epgId);
|
XML_ADD_TAG_LONG(*extMessage, MI_XML_TAG_ID, movie_info->epgId);
|
||||||
XML_ADD_TAG_STRING(*extMessage, MI_XML_TAG_INFO1, movie_info->epgInfo1);
|
XML_ADD_TAG_STRING(*extMessage, MI_XML_TAG_INFO1, movie_info->epgInfo1);
|
||||||
XML_ADD_TAG_STRING(*extMessage, MI_XML_TAG_INFO2, movie_info->epgInfo2);
|
XML_ADD_TAG_STRING(*extMessage, MI_XML_TAG_INFO2, movie_info->epgInfo2);
|
||||||
XML_ADD_TAG_LONG(*extMessage, MI_XML_TAG_EPGID, movie_info->epgEpgId); // %llu
|
XML_ADD_TAG_LONG(*extMessage, MI_XML_TAG_EPGID, movie_info->epgEpgId); // %llu
|
||||||
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_MODE, movie_info->epgMode); //%d
|
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_MODE, movie_info->epgMode); // %d
|
||||||
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_VIDEOPID, movie_info->epgVideoPid); //%u
|
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_VIDEOPID, movie_info->epgVideoPid); // %u
|
||||||
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_VIDEOTYPE, movie_info->VideoType); //%u
|
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_VIDEOTYPE, movie_info->VideoType); // %u
|
||||||
if ( !movie_info->audioPids.empty() ) {
|
if ( !movie_info->audioPids.empty() ) {
|
||||||
*extMessage += "\t\t<" MI_XML_TAG_AUDIOPIDS ">\n";
|
*extMessage += "\t\t<" MI_XML_TAG_AUDIOPIDS ">\n";
|
||||||
|
|
||||||
for (unsigned int i = 0; i < movie_info->audioPids.size(); i++) // pids.APIDs.size()
|
for (unsigned int i = 0; i < movie_info->audioPids.size(); i++) // pids.APIDs.size()
|
||||||
{
|
{
|
||||||
*extMessage += "\t\t\t<" MI_XML_TAG_AUDIO " " MI_XML_TAG_PID "=\"";
|
*extMessage += "\t\t\t<" MI_XML_TAG_AUDIO " " MI_XML_TAG_PID "=\"";
|
||||||
*extMessage += to_string(movie_info->audioPids[i].epgAudioPid);
|
*extMessage += to_string(movie_info->audioPids[i].epgAudioPid);
|
||||||
@@ -184,9 +132,8 @@ bool CMovieInfo::encodeMovieInfoXml(std::string * extMessage, MI_MOVIE_INFO * mo
|
|||||||
}
|
}
|
||||||
*extMessage += "\t\t</" MI_XML_TAG_AUDIOPIDS ">\n";
|
*extMessage += "\t\t</" MI_XML_TAG_AUDIOPIDS ">\n";
|
||||||
}
|
}
|
||||||
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_VTXTPID, movie_info->epgVTXPID); //%u
|
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_VTXTPID, movie_info->epgVTXPID); // %u
|
||||||
/*****************************************************
|
|
||||||
* new tags */
|
|
||||||
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_GENRE_MAJOR, movie_info->genreMajor);
|
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_GENRE_MAJOR, movie_info->genreMajor);
|
||||||
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_GENRE_MINOR, movie_info->genreMinor);
|
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_GENRE_MINOR, movie_info->genreMinor);
|
||||||
XML_ADD_TAG_STRING(*extMessage, MI_XML_TAG_SERIE_NAME, movie_info->serieName);
|
XML_ADD_TAG_STRING(*extMessage, MI_XML_TAG_SERIE_NAME, movie_info->serieName);
|
||||||
@@ -223,12 +170,11 @@ bool CMovieInfo::encodeMovieInfoXml(std::string * extMessage, MI_MOVIE_INFO * mo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
bool CMovieInfo::saveMovieInfo(MI_MOVIE_INFO & movie_info, CFile * file)
|
bool CMovieInfo::saveMovieInfo(MI_MOVIE_INFO & movie_info, CFile * file)
|
||||||
{
|
{
|
||||||
//TRACE("[mi]->saveXml \r\n");
|
//TRACE("[mi]->saveMovieInfo\n");
|
||||||
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
std::string text;
|
std::string text;
|
||||||
CFile file_xml;
|
CFile file_xml;
|
||||||
@@ -239,35 +185,35 @@ bool CMovieInfo::saveMovieInfo(MI_MOVIE_INFO & movie_info, CFile * file)
|
|||||||
} else {
|
} else {
|
||||||
file_xml.Name = file->Name;
|
file_xml.Name = file->Name;
|
||||||
}
|
}
|
||||||
TRACE("[mi] saveXml: %s\r\n", file_xml.Name.c_str());
|
TRACE("[mi] saveMovieInfo: %s\n", file_xml.Name.c_str());
|
||||||
|
|
||||||
if (result == true) {
|
if (result == true) {
|
||||||
result = encodeMovieInfoXml(&text, &movie_info);
|
result = encodeMovieInfoXml(&text, &movie_info);
|
||||||
if (result == true) {
|
if (result == true) {
|
||||||
result = saveFile(file_xml, text); // save
|
result = saveFile(file_xml, text); // save
|
||||||
if (result == false) {
|
if (result == false) {
|
||||||
TRACE("[mi] saveXml: save error\r\n");
|
TRACE("[mi] saveMovieInfo: save error\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TRACE("[mi] saveXml: encoding error\r\n");
|
TRACE("[mi] saveMovieInfo: encoding error\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TRACE("[mi] saveXml: error\r\n");
|
TRACE("[mi] saveMovieInfo: error\n");
|
||||||
}
|
}
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
bool CMovieInfo::loadMovieInfo(MI_MOVIE_INFO * movie_info, CFile * file)
|
bool CMovieInfo::loadMovieInfo(MI_MOVIE_INFO * movie_info, CFile * file)
|
||||||
{
|
{
|
||||||
//TRACE("[mi]->loadMovieInfo \r\n");
|
//TRACE("[mi]->loadMovieInfo\n");
|
||||||
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
CFile file_xml;
|
CFile file_xml;
|
||||||
|
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
// if there is no give file, we use the file name from movie info but we have to convert the ts name to xml name first
|
// if there is no give file, we use the file name from movie info
|
||||||
|
// but we have to convert the ts name to xml name first
|
||||||
file_xml.Name = movie_info->file.Name;
|
file_xml.Name = movie_info->file.Name;
|
||||||
result = convertTs2XmlName(file_xml.Name);
|
result = convertTs2XmlName(file_xml.Name);
|
||||||
} else {
|
} else {
|
||||||
@@ -278,296 +224,15 @@ bool CMovieInfo::loadMovieInfo(MI_MOVIE_INFO * movie_info, CFile * file)
|
|||||||
// load xml file in buffer
|
// load xml file in buffer
|
||||||
std::string text;
|
std::string text;
|
||||||
result = loadFile(file_xml, text);
|
result = loadFile(file_xml, text);
|
||||||
if (result == true) {
|
if (result == true)
|
||||||
#ifdef XMLTREE_LIB
|
|
||||||
result = parseXmlTree(text, movie_info);
|
result = parseXmlTree(text, movie_info);
|
||||||
#else /* XMLTREE_LIB */
|
|
||||||
result = parseXmlQuickFix(text, movie_info);
|
|
||||||
#endif /* XMLTREE_LIB */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (movie_info->productionDate > 50 && movie_info->productionDate < 200) // backwardcompaibility
|
if (movie_info->productionDate > 50 && movie_info->productionDate < 200) // backwardcompaibility
|
||||||
movie_info->productionDate += 1900;
|
movie_info->productionDate += 1900;
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
#if 0
|
|
||||||
//never used
|
|
||||||
bool CMovieInfo::parseXmlTree(char */*text*/, MI_MOVIE_INFO * /*movie_info*/)
|
|
||||||
{
|
|
||||||
#ifndef XMLTREE_LIB
|
|
||||||
return (false); // no XML lib available return false
|
|
||||||
#else /* XMLTREE_LIB */
|
|
||||||
|
|
||||||
//int helpIDtoLoad = 80;
|
|
||||||
|
|
||||||
//XMLTreeParser *parser=new XMLTreeParser("ISO-8859-1");
|
|
||||||
XMLTreeParser *parser = new XMLTreeParser(NULL);
|
|
||||||
|
|
||||||
if (!parser->Parse(text, strlen(text), 1)) {
|
|
||||||
TRACE("parse error: %s at line %d \r\n", parser->ErrorString(parser->GetErrorCode()), parser->GetCurrentLineNumber());
|
|
||||||
//fclose(in);
|
|
||||||
delete parser;
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
XMLTreeNode *root = parser->RootNode();
|
|
||||||
if (!root) {
|
|
||||||
TRACE(" root error \r\n");
|
|
||||||
delete parser;
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(root->GetType(), MI_XML_TAG_NEUTRINO)) {
|
|
||||||
TRACE("not neutrino file. %s", root->GetType());
|
|
||||||
delete parser;
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
XMLTreeNode *node = parser->RootNode();
|
|
||||||
|
|
||||||
for (node = node->GetChild(); node; node = node->GetNext()) {
|
|
||||||
if (!strcmp(node->GetType(), MI_XML_TAG_RECORD)) {
|
|
||||||
for (XMLTreeNode * xam1 = node->GetChild(); xam1; xam1 = xam1->GetNext()) {
|
|
||||||
XML_GET_DATA_STRING(xam1, MI_XML_TAG_CHANNELNAME, movie_info->epgChannel);
|
|
||||||
XML_GET_DATA_STRING(xam1, MI_XML_TAG_EPGTITLE, movie_info->epgTitle);
|
|
||||||
XML_GET_DATA_LONG(xam1, MI_XML_TAG_ID, movie_info->epgId);
|
|
||||||
XML_GET_DATA_STRING(xam1, MI_XML_TAG_INFO1, movie_info->epgInfo1);
|
|
||||||
XML_GET_DATA_STRING(xam1, MI_XML_TAG_INFO2, movie_info->epgInfo2);
|
|
||||||
XML_GET_DATA_LONG(xam1, MI_XML_TAG_EPGID, movie_info->epgEpgId); // %llu
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_MODE, movie_info->epgMode); //%d
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_VIDEOPID, movie_info->epgVideoPid); //%u
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_VIDEOTYPE, movie_info->VideoType); //%u
|
|
||||||
if (!strcmp(xam1->GetType(), MI_XML_TAG_AUDIOPIDS)) {
|
|
||||||
for (XMLTreeNode * xam2 = xam1->GetChild(); xam2; xam2 = xam2->GetNext()) {
|
|
||||||
if (!strcmp(xam2->GetType(), MI_XML_TAG_AUDIO)) {
|
|
||||||
EPG_AUDIO_PIDS pids;
|
|
||||||
pids.epgAudioPid = atoi(xam2->GetAttributeValue(MI_XML_TAG_PID));
|
|
||||||
pids.atype = atoi(xam2->GetAttributeValue(MI_XML_TAG_ATYPE));
|
|
||||||
pids.selected = atoi(xam2->GetAttributeValue(MI_XML_TAG_SELECTED));
|
|
||||||
pids.epgAudioPidName = decodeXmlSpecialChars(xam2->GetAttributeValue(MI_XML_TAG_NAME));
|
|
||||||
//printf("MOVIE INFO: apid %d type %d name %s selected %d\n", pids.epgAudioPid, pids.atype, pids.epgAudioPidName.c_str(), pids.selected);
|
|
||||||
movie_info->audioPids.push_back(pids);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_VTXTPID, movie_info->epgVTXPID); //%u
|
|
||||||
/*****************************************************
|
|
||||||
* new tags */
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_GENRE_MAJOR, movie_info->genreMajor);
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_GENRE_MINOR, movie_info->genreMinor);
|
|
||||||
XML_GET_DATA_STRING(xam1, MI_XML_TAG_SERIE_NAME, movie_info->serieName);
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_LENGTH, movie_info->length);
|
|
||||||
XML_GET_DATA_STRING(xam1, MI_XML_TAG_PRODUCT_COUNTRY, movie_info->productionCountry);
|
|
||||||
//if(!strcmp(xam1->GetType(), MI_XML_TAG_PRODUCT_COUNTRY)) if(xam1->GetData() != NULL)strncpy(movie_info->productionCountry, xam1->GetData(),4);
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_PRODUCT_DATE, movie_info->productionDate);
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_RATING, movie_info->rating);
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_QUALITIY, movie_info->quality);
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_QUALITY, movie_info->quality);
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_PARENTAL_LOCKAGE, movie_info->parentalLockAge);
|
|
||||||
XML_GET_DATA_INT(xam1, MI_XML_TAG_DATE_OF_LAST_PLAY, movie_info->dateOfLastPlay);
|
|
||||||
|
|
||||||
if (!strcmp(xam1->GetType(), MI_XML_TAG_BOOKMARK)) {
|
|
||||||
for (XMLTreeNode * xam2 = xam1->GetChild(); xam2; xam2 = xam2->GetNext()) {
|
|
||||||
XML_GET_DATA_INT(xam2, MI_XML_TAG_BOOKMARK_START, movie_info->bookmarks.start);
|
|
||||||
XML_GET_DATA_INT(xam2, MI_XML_TAG_BOOKMARK_END, movie_info->bookmarks.end);
|
|
||||||
XML_GET_DATA_INT(xam2, MI_XML_TAG_BOOKMARK_LAST, movie_info->bookmarks.lastPlayStop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*****************************************************/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete parser;
|
|
||||||
if (movie_info->epgInfo2.empty()) {
|
|
||||||
movie_info->epgInfo2 = movie_info->epgInfo1;
|
|
||||||
//movie_info->epgInfo1 = "";
|
|
||||||
}
|
|
||||||
#endif /* XMLTREE_LIB */
|
|
||||||
return (true);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
#if 0
|
|
||||||
void CMovieInfo::showMovieInfo(MI_MOVIE_INFO & movie_info)
|
|
||||||
{
|
|
||||||
std::string print_buffer = movie_info.epgInfo1;
|
|
||||||
print_buffer += "\n";
|
|
||||||
if (movie_info.epgInfo1 != movie_info.epgInfo2) {
|
|
||||||
print_buffer += movie_info.epgInfo2;
|
|
||||||
print_buffer += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !movie_info.productionCountry.empty() || movie_info.productionDate != 0) {
|
|
||||||
print_buffer += movie_info.productionCountry;
|
|
||||||
print_buffer += to_string(movie_info.productionDate + 1900);
|
|
||||||
print_buffer += "\n";
|
|
||||||
}
|
|
||||||
if (!movie_info.serieName.empty()) {
|
|
||||||
print_buffer += "\n";
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_SERIE);
|
|
||||||
print_buffer += ": ";
|
|
||||||
print_buffer += movie_info.serieName;
|
|
||||||
print_buffer += "\n";
|
|
||||||
}
|
|
||||||
if (!movie_info.epgChannel.empty()) {
|
|
||||||
print_buffer += "\n";
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_CHANNEL);
|
|
||||||
print_buffer += ": ";
|
|
||||||
print_buffer += movie_info.epgChannel;
|
|
||||||
print_buffer += "\n";
|
|
||||||
}
|
|
||||||
if (movie_info.rating != 0) {
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_RATING);
|
|
||||||
print_buffer += ": ";
|
|
||||||
print_buffer += to_string(movie_info.rating / 10);
|
|
||||||
print_buffer += ",";
|
|
||||||
print_buffer += to_string(movie_info.rating % 10);
|
|
||||||
print_buffer += "/10";
|
|
||||||
print_buffer += "\n";
|
|
||||||
}
|
|
||||||
if (movie_info.quality != 0) {
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_QUALITY);
|
|
||||||
print_buffer += ": ";
|
|
||||||
print_buffer += to_string(movie_info.quality);
|
|
||||||
print_buffer += "\n";
|
|
||||||
}
|
|
||||||
if (movie_info.parentalLockAge != 0) {
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_PARENTAL_LOCKAGE);
|
|
||||||
print_buffer += ": ";
|
|
||||||
print_buffer += to_string(movie_info.parentalLockAge);
|
|
||||||
print_buffer += " ";
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_UNIT_LONG_YEARS);
|
|
||||||
print_buffer += "\n";
|
|
||||||
}
|
|
||||||
if (movie_info.length != 0) {
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_LENGTH);
|
|
||||||
print_buffer += ": ";
|
|
||||||
print_buffer += to_string(movie_info.length);
|
|
||||||
print_buffer += "\n";
|
|
||||||
}
|
|
||||||
if ( !movie_info.audioPids.empty() ) {
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_AUDIO);
|
|
||||||
print_buffer += ": ";
|
|
||||||
for (unsigned int i = 0; i < movie_info.audioPids.size(); i++) {
|
|
||||||
if (i)
|
|
||||||
print_buffer += ", ";
|
|
||||||
print_buffer += movie_info.audioPids[i].epgAudioPidName;
|
|
||||||
}
|
|
||||||
print_buffer += "\n";
|
|
||||||
}
|
|
||||||
if (movie_info.genreMajor != 0)
|
|
||||||
{
|
|
||||||
neutrino_locale_t locale_genre;
|
|
||||||
unsigned char i = (movie_info.genreMajor & 0x0F0);
|
|
||||||
if (i >= 0x010 && i < 0x0B0)
|
|
||||||
{
|
|
||||||
i >>= 4;
|
|
||||||
i--;
|
|
||||||
locale_genre = genre_sub_classes_list[i][((movie_info.genreMajor & 0x0F) < genre_sub_classes[i]) ? (movie_info.genreMajor & 0x0F) : 0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
locale_genre = LOCALE_GENRE_UNKNOWN;
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_GENRE_MAJOR);
|
|
||||||
print_buffer += ": ";
|
|
||||||
print_buffer += g_Locale->getText(locale_genre);
|
|
||||||
print_buffer += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
tm *date_tm = localtime(&movie_info.dateOfLastPlay);
|
|
||||||
print_buffer += "\n";
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_PREVPLAYDATE);
|
|
||||||
print_buffer += ": ";
|
|
||||||
print_buffer += strftime("%F", date_tm);
|
|
||||||
print_buffer += "\n";
|
|
||||||
|
|
||||||
date_tm = localtime(&movie_info.file.Time);
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_RECORDDATE);
|
|
||||||
print_buffer += ": ";
|
|
||||||
print_buffer += strftime("%F", date_tm);
|
|
||||||
print_buffer += "\n";
|
|
||||||
|
|
||||||
if (movie_info.file.Size != 0) {
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_SIZE);
|
|
||||||
print_buffer += ": ";
|
|
||||||
print_buffer += to_string(movie_info.file.Size >> 20);
|
|
||||||
print_buffer += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_FILE);
|
|
||||||
print_buffer += ": ";
|
|
||||||
print_buffer += movie_info.file.Name;
|
|
||||||
print_buffer += "\n";
|
|
||||||
|
|
||||||
ShowMsg2UTF(movie_info.epgTitle.empty()? movie_info.file.getFileName().c_str() : movie_info.epgTitle.c_str(), print_buffer.c_str(), CMsgBox::mbrBack, CMsgBox::mbBack); // UTF-8*/
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
#if 0
|
|
||||||
//never used
|
|
||||||
void CMovieInfo::printDebugMovieInfo(MI_MOVIE_INFO & movie_info)
|
|
||||||
{
|
|
||||||
TRACE(" FileName: %s", movie_info.file.Name.c_str());
|
|
||||||
//TRACE(" FilePath: %s", movie_info.file.GetFilePath );
|
|
||||||
//TRACE(" FileLength: %d", movie_info.file.GetLength );
|
|
||||||
//TRACE(" FileStatus: %d", movie_info.file.GetStatus );
|
|
||||||
|
|
||||||
TRACE(" ********** Movie Data ***********\r\n"); // (date, month, year)
|
|
||||||
TRACE(" dateOfLastPlay: \t%d\r\n", (int)movie_info.dateOfLastPlay); // (date, month, year)
|
|
||||||
TRACE(" dirItNr: \t\t%d\r\n", movie_info.dirItNr); //
|
|
||||||
TRACE(" genreMajor: \t\t%d\r\n", movie_info.genreMajor); //genreMajor;
|
|
||||||
TRACE(" genreMinor: \t\t%d\r\n", movie_info.genreMinor); //genreMinor;
|
|
||||||
TRACE(" length: \t\t%d\r\n", movie_info.length); // (minutes)
|
|
||||||
TRACE(" rating: \t\t%d,%d\r\n", movie_info.rating / 10, movie_info.rating % 10); // user rating (like IMDb rating; 75 means 7.5/10)
|
|
||||||
TRACE(" quality: \t\t%d\r\n", movie_info.quality); // (3 stars: classics, 2 stars: very good, 1 star: good, 0 stars: OK)
|
|
||||||
TRACE(" productionCount:\t>%s<\r\n", movie_info.productionCountry.c_str());
|
|
||||||
TRACE(" productionDate: \t%d\r\n", movie_info.productionDate); // (Year) years since 1900
|
|
||||||
TRACE(" parentalLockAge: \t\t\t%d\r\n", movie_info.parentalLockAge); // MI_PARENTAL_LOCKAGE (0,6,12,16,18)
|
|
||||||
TRACE(" format: \t\t%d\r\n", movie_info.format); // MI_VIDEO_FORMAT(16:9, 4:3)
|
|
||||||
TRACE(" audio: \t\t%d\r\n", movie_info.audio); // MI_AUDIO (AC3, Deutsch, Englisch)
|
|
||||||
TRACE(" epgId: \t\t%d\r\n", (int)movie_info.epgId);
|
|
||||||
TRACE(" epgEpgId: \t\t%llu\r\n", movie_info.epgEpgId);
|
|
||||||
TRACE(" epgMode: \t\t%d\r\n", movie_info.epgMode);
|
|
||||||
TRACE(" epgVideoPid: \t\t%d\r\n", movie_info.epgVideoPid);
|
|
||||||
TRACE(" epgVTXPID: \t\t%d\r\n", movie_info.epgVTXPID);
|
|
||||||
TRACE(" Size: \t\t%d\r\n", (int)movie_info.file.Size >> 20);
|
|
||||||
TRACE(" Date: \t\t%d\r\n", (int)movie_info.file.Time);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < movie_info.audioPids.size(); i++) {
|
|
||||||
TRACE(" audioPid (%d): \t\t%d\r\n", i, movie_info.audioPids[i].epgAudioPid);
|
|
||||||
TRACE(" audioName(%d): \t\t>%s<\r\n", i, movie_info.audioPids[i].epgAudioPidName.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE(" epgTitle: \t\t>%s<\r\n", movie_info.epgTitle.c_str());
|
|
||||||
TRACE(" epgInfo1:\t\t>%s<\r\n", movie_info.epgInfo1.c_str()); //epgInfo1
|
|
||||||
TRACE(" epgInfo2:\t\t\t>%s<\r\n", movie_info.epgInfo2.c_str()); //epgInfo2
|
|
||||||
TRACE(" epgChannel:\t\t>%s<\r\n", movie_info.epgChannel.c_str());
|
|
||||||
TRACE(" serieName:\t\t>%s<\r\n", movie_info.serieName.c_str()); // (name e.g. 'StarWars)
|
|
||||||
|
|
||||||
TRACE(" bookmarks start: \t%d\r\n", movie_info.bookmarks.start);
|
|
||||||
TRACE(" bookmarks end: \t%d\r\n", movie_info.bookmarks.end);
|
|
||||||
TRACE(" bookmarks lastPlayStop: %d\r\n", movie_info.bookmarks.lastPlayStop);
|
|
||||||
|
|
||||||
for (int i = 0; i < MI_MOVIE_BOOK_USER_MAX; i++) {
|
|
||||||
if (movie_info.bookmarks.user[i].pos != 0 || i == 0) {
|
|
||||||
TRACE(" bookmarks user, pos:%d, type:%d, name: >%s<\r\n", movie_info.bookmarks.user[i].pos, movie_info.bookmarks.user[i].length, movie_info.bookmarks.user[i].name.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
static int find_next_char(char to_find, const char *text, int start_pos, int end_pos)
|
static int find_next_char(char to_find, const char *text, int start_pos, int end_pos)
|
||||||
{
|
{
|
||||||
while (start_pos < end_pos) {
|
while (start_pos < end_pos) {
|
||||||
@@ -607,14 +272,13 @@ static int find_next_char(char to_find, const char *text, int start_pos, int end
|
|||||||
_pos_ += sizeof(_tag_) ;\
|
_pos_ += sizeof(_tag_) ;\
|
||||||
int pos_prev = _pos_;\
|
int pos_prev = _pos_;\
|
||||||
while(_pos_ < bytes && _text_[_pos_] != '<' ) pos++;\
|
while(_pos_ < bytes && _text_[_pos_] != '<' ) pos++;\
|
||||||
_dest_ = strtoull(&_text_[pos_prev], NULL, 10); /*atoll(&_text_[pos_prev]);*/\
|
_dest_ = strtoull(&_text_[pos_prev], NULL, 10);\
|
||||||
continue;\
|
continue;\
|
||||||
}
|
}
|
||||||
|
|
||||||
//void CMovieInfo::strReplace(std::string& orig, const char* fstr, const std::string rstr)
|
void strReplace(std::string &orig, const char *fstr, const std::string &rstr)
|
||||||
void strReplace(std::string & orig, const char *fstr, const std::string &rstr)
|
|
||||||
{
|
{
|
||||||
// replace all occurrence of fstr with rstr and, and returns a reference to itself
|
// replace all occurrence of fstr with rstr and returns a reference to itself
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
size_t fstrlen = strlen(fstr);
|
size_t fstrlen = strlen(fstr);
|
||||||
size_t rstrlen = rstr.size();
|
size_t rstrlen = rstr.size();
|
||||||
@@ -637,18 +301,15 @@ std::string decodeXmlSpecialChars(std::string s)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
bool CMovieInfo::parseXmlTree(std::string &_text, MI_MOVIE_INFO *movie_info)
|
||||||
************************************************************************/
|
|
||||||
bool CMovieInfo::parseXmlQuickFix(std::string &_text, MI_MOVIE_INFO * movie_info)
|
|
||||||
{
|
{
|
||||||
#ifndef XMLTREE_LIB
|
|
||||||
int bookmark_nr = 0;
|
int bookmark_nr = 0;
|
||||||
movie_info->dateOfLastPlay = 0; //100*366*24*60*60; // (date, month, year)
|
movie_info->dateOfLastPlay = 0; //100*366*24*60*60; // (date, month, year)
|
||||||
//bool result = false;
|
//bool result = false;
|
||||||
|
|
||||||
const char *text = _text.c_str();
|
const char *text = _text.c_str();
|
||||||
int bytes = _text.length();
|
int bytes = _text.length();
|
||||||
/** search ****/
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
EPG_AUDIO_PIDS audio_pids;
|
EPG_AUDIO_PIDS audio_pids;
|
||||||
@@ -756,10 +417,10 @@ bool CMovieInfo::parseXmlQuickFix(std::string &_text, MI_MOVIE_INFO * movie_info
|
|||||||
}
|
}
|
||||||
/* parse bookmarks */
|
/* parse bookmarks */
|
||||||
GET_XML_DATA_INT(text, pos, MI_XML_TAG_BOOKMARK_START, movie_info->bookmarks.start)
|
GET_XML_DATA_INT(text, pos, MI_XML_TAG_BOOKMARK_START, movie_info->bookmarks.start)
|
||||||
GET_XML_DATA_INT(text, pos, MI_XML_TAG_BOOKMARK_END, movie_info->bookmarks.end)
|
GET_XML_DATA_INT(text, pos, MI_XML_TAG_BOOKMARK_END, movie_info->bookmarks.end)
|
||||||
GET_XML_DATA_INT(text, pos, MI_XML_TAG_BOOKMARK_LAST, movie_info->bookmarks.lastPlayStop)
|
GET_XML_DATA_INT(text, pos, MI_XML_TAG_BOOKMARK_LAST, movie_info->bookmarks.lastPlayStop)
|
||||||
|
|
||||||
if (bookmark_nr < MI_MOVIE_BOOK_USER_MAX) {
|
if (bookmark_nr < MI_MOVIE_BOOK_USER_MAX) {
|
||||||
if (strncmp(&text[pos], MI_XML_TAG_BOOKMARK_USER, sizeof(MI_XML_TAG_BOOKMARK_USER) - 1) == 0) {
|
if (strncmp(&text[pos], MI_XML_TAG_BOOKMARK_USER, sizeof(MI_XML_TAG_BOOKMARK_USER) - 1) == 0) {
|
||||||
pos += sizeof(MI_XML_TAG_BOOKMARK_USER);
|
pos += sizeof(MI_XML_TAG_BOOKMARK_USER);
|
||||||
//int pos2 = strcspn(&text[pos],MI_XML_TAG_BOOKMARK_USER_POS);
|
//int pos2 = strcspn(&text[pos],MI_XML_TAG_BOOKMARK_USER_POS);
|
||||||
@@ -816,16 +477,13 @@ bool CMovieInfo::parseXmlQuickFix(std::string &_text, MI_MOVIE_INFO * movie_info
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (true);
|
return (true);
|
||||||
#endif
|
|
||||||
return (false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
bool CMovieInfo::addNewBookmark(MI_MOVIE_INFO * movie_info, MI_BOOKMARK & new_bookmark)
|
bool CMovieInfo::addNewBookmark(MI_MOVIE_INFO * movie_info, MI_BOOKMARK & new_bookmark)
|
||||||
{
|
{
|
||||||
TRACE("[mi] addNewBookmark\r\n");
|
TRACE("[mi] addNewBookmark\n");
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (movie_info != NULL) {
|
if (movie_info != NULL) {
|
||||||
// search for free entry
|
// search for free entry
|
||||||
@@ -854,9 +512,6 @@ bool CMovieInfo::addNewBookmark(MI_MOVIE_INFO * movie_info, MI_BOOKMARK & new_bo
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
|
|
||||||
void MI_MOVIE_INFO::clear(void)
|
void MI_MOVIE_INFO::clear(void)
|
||||||
{
|
{
|
||||||
@@ -870,19 +525,19 @@ void MI_MOVIE_INFO::clear(void)
|
|||||||
|
|
||||||
file.Name = "";
|
file.Name = "";
|
||||||
file.Url = "";
|
file.Url = "";
|
||||||
file.Size = 0; // Megabytes
|
file.Size = 0; // Megabytes
|
||||||
file.Time = mktime(&timePlay);
|
file.Time = mktime(&timePlay);
|
||||||
dateOfLastPlay = mktime(&timePlay); // (date, month, year)
|
dateOfLastPlay = mktime(&timePlay);
|
||||||
dirItNr = 0; //
|
dirItNr = 0;
|
||||||
genreMajor = 0; //genreMajor;
|
genreMajor = 0;
|
||||||
genreMinor = 0; //genreMinor;
|
genreMinor = 0;
|
||||||
length = 0; // (minutes)
|
length = 0;
|
||||||
rating = 0; // (like IMDb rating)
|
rating = 0;
|
||||||
quality = 0; // (3 stars: classics, 2 stars: very good, 1 star: good, 0 stars: OK)
|
quality = 0;
|
||||||
productionDate = 0; // (Year) years since 1900
|
productionDate = 0;
|
||||||
parentalLockAge = 0; // MI_PARENTAL_LOCKAGE (0,6,12,16,18)
|
parentalLockAge = 0;
|
||||||
// format = 0; // MI_VIDEO_FORMAT(16:9, 4:3)
|
//format = 0;
|
||||||
// audio = 0; // MI_AUDIO (AC3, Deutsch, Englisch)
|
//audio = 0;
|
||||||
|
|
||||||
epgId = 0;
|
epgId = 0;
|
||||||
epgEpgId = 0;
|
epgEpgId = 0;
|
||||||
@@ -895,10 +550,10 @@ void MI_MOVIE_INFO::clear(void)
|
|||||||
|
|
||||||
productionCountry = "";
|
productionCountry = "";
|
||||||
epgTitle = "";
|
epgTitle = "";
|
||||||
epgInfo1 = ""; //epgInfo1
|
epgInfo1 = "";
|
||||||
epgInfo2 = ""; //epgInfo2
|
epgInfo2 = "";
|
||||||
epgChannel = "";
|
epgChannel = "";
|
||||||
serieName = ""; // (name e.g. 'StarWars)
|
serieName = "";
|
||||||
bookmarks.end = 0;
|
bookmarks.end = 0;
|
||||||
bookmarks.start = 0;
|
bookmarks.start = 0;
|
||||||
bookmarks.lastPlayStop = 0;
|
bookmarks.lastPlayStop = 0;
|
||||||
@@ -908,24 +563,23 @@ void MI_MOVIE_INFO::clear(void)
|
|||||||
bookmarks.user[i].name = "";
|
bookmarks.user[i].name = "";
|
||||||
}
|
}
|
||||||
tfile = "";
|
tfile = "";
|
||||||
|
|
||||||
ytdate = "";
|
ytdate = "";
|
||||||
ytid = "";
|
ytid = "";
|
||||||
ytitag = 0;
|
ytitag = 0;
|
||||||
|
|
||||||
marked = false;
|
marked = false;
|
||||||
delAsk = true;
|
delAsk = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
bool CMovieInfo::loadFile(CFile &file, std::string &buffer)
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
bool CMovieInfo::loadFile(CFile & file, std::string &buffer)
|
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
int fd = open(file.Name.c_str(), O_RDONLY);
|
int fd = open(file.Name.c_str(), O_RDONLY);
|
||||||
if (fd == -1) // cannot open file, return!!!!!
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
TRACE("[mi] loadXml: cannot open (%s)\r\n", file.Name.c_str());
|
TRACE("[mi] loadFile: cannot open (%s)\n", file.Name.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@@ -935,7 +589,7 @@ bool CMovieInfo::loadFile(CFile & file, std::string &buffer)
|
|||||||
}
|
}
|
||||||
char buf[st.st_size];
|
char buf[st.st_size];
|
||||||
if (st.st_size != read(fd, buf, st.st_size)) {
|
if (st.st_size != read(fd, buf, st.st_size)) {
|
||||||
TRACE("[mi] loadXml: cannot read (%s)\r\n", file.Name.c_str());
|
TRACE("[mi] loadFile: cannot read (%s)\n", file.Name.c_str());
|
||||||
result = false;
|
result = false;
|
||||||
} else
|
} else
|
||||||
buffer = std::string(buf, st.st_size);
|
buffer = std::string(buf, st.st_size);
|
||||||
@@ -945,22 +599,18 @@ bool CMovieInfo::loadFile(CFile & file, std::string &buffer)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
bool CMovieInfo::saveFile(const CFile & file, std::string &text)
|
bool CMovieInfo::saveFile(const CFile & file, std::string &text)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
int fd;
|
int fd;
|
||||||
if ((fd = open(file.Name.c_str(), O_SYNC | O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) {
|
if ((fd = open(file.Name.c_str(), O_SYNC | O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) {
|
||||||
/*int nr=*/
|
|
||||||
write(fd, text.c_str(), text.size());
|
write(fd, text.c_str(), text.size());
|
||||||
//fdatasync(fd);
|
//fdatasync(fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
result = true;
|
result = true;
|
||||||
//TRACE("[mi] saved (%d)\r\n",nr);
|
//TRACE("[mi] saved (%d)\n",nr);
|
||||||
} else {
|
} else {
|
||||||
TRACE("[mi] ERROR: cannot open\r\n");
|
TRACE("[mi] ERROR: cannot open\n");
|
||||||
}
|
}
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,8 @@
|
|||||||
/***************************************************************************
|
/*
|
||||||
Neutrino-GUI - DBoxII-Project
|
movieinfo - Neutrino-GUI
|
||||||
|
|
||||||
Homepage: http://dbox.cyberphoria.org/
|
|
||||||
|
|
||||||
Kommentar:
|
|
||||||
|
|
||||||
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
|
|
||||||
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
|
|
||||||
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
|
|
||||||
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
|
|
||||||
|
|
||||||
|
Copyright (C) 2005 Günther <Günther@tuxbox.berlios.org>
|
||||||
|
Copyright (C) 2015 Sven Hoefer (svenhoefer)
|
||||||
|
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
||||||
@@ -27,21 +20,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
***********************************************************
|
*/
|
||||||
|
|
||||||
Module Name: movieinfo.h .
|
|
||||||
|
|
||||||
Description: implementation of the CMovieInfo class
|
|
||||||
|
|
||||||
Date: Nov 2005
|
|
||||||
|
|
||||||
Author: Günther@tuxbox.berlios.org
|
|
||||||
|
|
||||||
Revision History:
|
|
||||||
Date Author Change Description
|
|
||||||
Nov 2005 Günther initial start
|
|
||||||
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef MOVIEINFO_H_
|
#ifndef MOVIEINFO_H_
|
||||||
#define MOVIEINFO_H_
|
#define MOVIEINFO_H_
|
||||||
@@ -57,137 +36,132 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "driver/file.h"
|
#include "driver/file.h"
|
||||||
|
|
||||||
/************************************************************************/
|
|
||||||
/************************************************************************/
|
|
||||||
/***************** CMovieInfo ********************************/
|
|
||||||
/************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/* XML tags for xml file*/
|
/* XML tags for xml file*/
|
||||||
#define MI_XML_TAG_NEUTRINO "neutrino"
|
#define MI_XML_TAG_NEUTRINO "neutrino"
|
||||||
#define MI_XML_TAG_RECORD "record"
|
#define MI_XML_TAG_RECORD "record"
|
||||||
|
#define MI_XML_TAG_CHANNELNAME "channelname"
|
||||||
#define MI_XML_TAG_CHANNELNAME "channelname"
|
#define MI_XML_TAG_EPGTITLE "epgtitle"
|
||||||
#define MI_XML_TAG_EPGTITLE "epgtitle"
|
#define MI_XML_TAG_ID "id"
|
||||||
#define MI_XML_TAG_ID "id"
|
#define MI_XML_TAG_INFO1 "info1"
|
||||||
#define MI_XML_TAG_INFO1 "info1"
|
#define MI_XML_TAG_INFO2 "info2"
|
||||||
#define MI_XML_TAG_INFO2 "info2"
|
#define MI_XML_TAG_EPGID "epgid"
|
||||||
#define MI_XML_TAG_EPGID "epgid"
|
#define MI_XML_TAG_MODE "mode"
|
||||||
#define MI_XML_TAG_MODE "mode"
|
#define MI_XML_TAG_VIDEOPID "videopid"
|
||||||
#define MI_XML_TAG_VIDEOPID "videopid"
|
#define MI_XML_TAG_VIDEOTYPE "videotype"
|
||||||
#define MI_XML_TAG_VIDEOTYPE "videotype"
|
#define MI_XML_TAG_AUDIOPIDS "audiopids"
|
||||||
#define MI_XML_TAG_AUDIOPIDS "audiopids"
|
#define MI_XML_TAG_AUDIO "audio"
|
||||||
#define MI_XML_TAG_AUDIO "audio"
|
#define MI_XML_TAG_PID "pid"
|
||||||
#define MI_XML_TAG_PID "pid"
|
#define MI_XML_TAG_NAME "name"
|
||||||
#define MI_XML_TAG_NAME "name"
|
#define MI_XML_TAG_ATYPE "audiotype"
|
||||||
#define MI_XML_TAG_ATYPE "audiotype"
|
#define MI_XML_TAG_SELECTED "selected"
|
||||||
#define MI_XML_TAG_SELECTED "selected"
|
#define MI_XML_TAG_VTXTPID "vtxtpid"
|
||||||
#define MI_XML_TAG_VTXTPID "vtxtpid"
|
#define MI_XML_TAG_GENRE_MAJOR "genremajor"
|
||||||
#define MI_XML_TAG_GENRE_MAJOR "genremajor"
|
#define MI_XML_TAG_GENRE_MINOR "genreminor"
|
||||||
#define MI_XML_TAG_GENRE_MINOR "genreminor"
|
#define MI_XML_TAG_SERIE_NAME "seriename"
|
||||||
#define MI_XML_TAG_SERIE_NAME "seriename"
|
#define MI_XML_TAG_LENGTH "length"
|
||||||
#define MI_XML_TAG_LENGTH "length"
|
#define MI_XML_TAG_PRODUCT_COUNTRY "productioncountry"
|
||||||
#define MI_XML_TAG_PRODUCT_COUNTRY "productioncountry"
|
#define MI_XML_TAG_PRODUCT_DATE "productiondate"
|
||||||
#define MI_XML_TAG_PRODUCT_DATE "productiondate"
|
|
||||||
#define MI_XML_TAG_RATING "rating"
|
#define MI_XML_TAG_RATING "rating"
|
||||||
#define MI_XML_TAG_QUALITY "quality"
|
#define MI_XML_TAG_QUALITY "quality"
|
||||||
#define MI_XML_TAG_QUALITIY "qualitiy" // just to keep compatibility to older xml-files
|
#define MI_XML_TAG_QUALITIY "qualitiy" // just to keep compatibility to older xml-files
|
||||||
#define MI_XML_TAG_PARENTAL_LOCKAGE "parentallockage"
|
#define MI_XML_TAG_PARENTAL_LOCKAGE "parentallockage"
|
||||||
#define MI_XML_TAG_BOOKMARK "bookmark"
|
#define MI_XML_TAG_BOOKMARK "bookmark"
|
||||||
#define MI_XML_TAG_BOOKMARK_START "bookmarkstart"
|
#define MI_XML_TAG_BOOKMARK_START "bookmarkstart"
|
||||||
#define MI_XML_TAG_BOOKMARK_END "bookmarkend"
|
#define MI_XML_TAG_BOOKMARK_END "bookmarkend"
|
||||||
#define MI_XML_TAG_BOOKMARK_LAST "bookmarklast"
|
#define MI_XML_TAG_BOOKMARK_LAST "bookmarklast"
|
||||||
#define MI_XML_TAG_BOOKMARK_USER "bookmarkuser"
|
#define MI_XML_TAG_BOOKMARK_USER "bookmarkuser"
|
||||||
#define MI_XML_TAG_BOOKMARK_USER_POS "bookmarkuserpos"
|
#define MI_XML_TAG_BOOKMARK_USER_POS "bookmarkuserpos"
|
||||||
#define MI_XML_TAG_BOOKMARK_USER_TYPE "bookmarkusertype"
|
#define MI_XML_TAG_BOOKMARK_USER_TYPE "bookmarkusertype"
|
||||||
#define MI_XML_TAG_BOOKMARK_USER_NAME "bookmarkusername"
|
#define MI_XML_TAG_BOOKMARK_USER_NAME "bookmarkusername"
|
||||||
#define MI_XML_TAG_DATE_OF_LAST_PLAY "dateoflastplay"
|
#define MI_XML_TAG_DATE_OF_LAST_PLAY "dateoflastplay"
|
||||||
|
|
||||||
|
#define MI_MAX_AUDIO_PIDS 4 // just to avoid the buffer is filled endless, might be increased later on , but 4 audio pids might be enough
|
||||||
#define MI_MAX_AUDIO_PIDS 4 // just to avoid the buffer is filled endless, might be increased later on , but 4 audio pids might be enough
|
#define MI_MOVIE_BOOK_USER_MAX 20 // just to avoid the buffer is filled endless, might be increased later on. Make sure to increase the bookmark menu as well
|
||||||
#define MI_MOVIE_BOOK_USER_MAX 20 // just to avoid the buffer is filled endless, might be increased later on. Make sure to increase the bookmark menu as well
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
MI_PARENTAL_OVER0 = 0,
|
MI_PARENTAL_OVER0 = 0,
|
||||||
MI_PARENTAL_OVER6 = 6,
|
MI_PARENTAL_OVER6 = 6,
|
||||||
MI_PARENTAL_OVER12 = 12,
|
MI_PARENTAL_OVER12 = 12,
|
||||||
MI_PARENTAL_OVER16 = 16,
|
MI_PARENTAL_OVER16 = 16,
|
||||||
MI_PARENTAL_OVER18 = 18,
|
MI_PARENTAL_OVER18 = 18,
|
||||||
MI_PARENTAL_ALWAYS = 99,
|
MI_PARENTAL_ALWAYS = 99,
|
||||||
MI_PARENTAL_MAX_NUMBER = 100
|
MI_PARENTAL_MAX_NUMBER = 100
|
||||||
}MI_PARENTAL_LOCKAGE;
|
} MI_PARENTAL_LOCKAGE;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int pos; // position in seconds from file start
|
int pos; // position in seconds from file start
|
||||||
int length; // bookmark type, 0: just a bookmark, < 0 jump back (seconds), > 0 jump forward (seconds)
|
int length; // bookmark type, 0: just a bookmark, < 0 jump back (seconds), > 0 jump forward (seconds)
|
||||||
std::string name; // bookmark name to be displayed
|
std::string name; // bookmark name to be displayed
|
||||||
}MI_BOOKMARK;
|
} MI_BOOKMARK;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int start; // movie start in seconds from file start
|
int start; // movie start in seconds from file start
|
||||||
int end; // movie end in seconds from file start
|
int end; // movie end in seconds from file start
|
||||||
int lastPlayStop; // position of last play stop in seconds from file start
|
int lastPlayStop; // position of last play stop in seconds from file start
|
||||||
MI_BOOKMARK user[MI_MOVIE_BOOK_USER_MAX]; // other user defined bookmarks
|
MI_BOOKMARK user[MI_MOVIE_BOOK_USER_MAX]; // other user defined bookmarks
|
||||||
}MI_MOVIE_BOOKMARKS;
|
} MI_MOVIE_BOOKMARKS;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int atype;
|
int atype;
|
||||||
int selected;
|
int selected;
|
||||||
int epgAudioPid; // epg audio pid nr, usually filled by VCR
|
int epgAudioPid; // epg audio pid nr, usually filled by VCR
|
||||||
std::string epgAudioPidName; // epg audio pid name, usually filled by VCR
|
std::string epgAudioPidName; // epg audio pid name, usually filled by VCR
|
||||||
}EPG_AUDIO_PIDS;
|
} EPG_AUDIO_PIDS;
|
||||||
|
|
||||||
/************************************************************************/
|
class MI_MOVIE_INFO //MI_MOVIE_INFO &operator=(const MI_MOVIE_INFO& src);
|
||||||
/************************************************************************/
|
|
||||||
|
|
||||||
class MI_MOVIE_INFO
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//MI_MOVIE_INFO &operator=(const MI_MOVIE_INFO& src);
|
CFile file; // not stored in xml
|
||||||
CFile file; // not stored in xml
|
std::string productionCountry; // user defined Country (not from EPG yet, but might be possible)
|
||||||
std::string productionCountry; // user defined Country (not from EPG yet, but might be possible)
|
std::string epgTitle; // plain movie name, usually filled by EPG
|
||||||
std::string epgTitle; // plain movie name, usually filled by EPG
|
std::string epgInfo1; // used for Genre (Premiere) or second title, usually filled by EPG
|
||||||
std::string epgInfo1; // used for Genre (Premiere) or second title, usually filled by EPG
|
std::string epgInfo2; // detailed movie content, usually filled by EPG
|
||||||
std::string epgInfo2; // detailed movie content, usually filled by EPG
|
std::string epgChannel; // Channel name, usually filled by EPG
|
||||||
std::string epgChannel; // Channel name, usually filled by EPG
|
std::string serieName; // user defines series name
|
||||||
std::string serieName; // user defines series name
|
|
||||||
|
|
||||||
time_t dateOfLastPlay; // last play date of movie in seconds since 1970
|
time_t dateOfLastPlay; // last play date of movie in seconds since 1970
|
||||||
int dirItNr; // handle for quick directory path access only, this is not saved in xml, might be used by the owner of the movie info struct
|
int dirItNr; // handle for quick directory path access only, this is not saved in xml, might be used by the owner of the movie info struct
|
||||||
int genreMajor; // see showEPG class for more info, usually filled by EPG
|
int genreMajor; // see showEPG class for more info, usually filled by EPG
|
||||||
char genreMinor; // genreMinor not used so far
|
char genreMinor; // genreMinor not used so far
|
||||||
int length; // movie length in minutes, usually filled by EPG
|
int length; // movie length in minutes, usually filled by EPG
|
||||||
int rating; // user rating (like IMDb rating; 75 means 7.5/10)
|
int rating; // user rating (like IMDb rating; 75 means 7.5/10)
|
||||||
int quality; // user classification (3 stars: classics, 2 stars: very good, 1 star: good, 0 stars: OK)
|
int quality; // user classification (3 stars: classics, 2 stars: very good, 1 star: good, 0 stars: OK)
|
||||||
int productionDate; // user defined Country (not from EPG yet, but might be possible)
|
int productionDate; // user defined Country (not from EPG yet, but might be possible)
|
||||||
int parentalLockAge; // used for age rating(0:never,6,12,16,18 years,99:always), usually filled by EPG (if available)
|
int parentalLockAge; // used for age rating(0:never,6,12,16,18 years,99:always), usually filled by EPG (if available)
|
||||||
//char format; // currently not used
|
//char format; // currently not used
|
||||||
//char audio; // currently not used
|
//char audio; // currently not used
|
||||||
MI_MOVIE_BOOKMARKS bookmarks; // bookmark collecton for this movie
|
MI_MOVIE_BOOKMARKS bookmarks; // bookmark collecton for this movie
|
||||||
std::vector<EPG_AUDIO_PIDS> audioPids; // available AudioPids, usually filled by VCR. Note: Vectors are easy to is also using the heap (memory fragmentation), might be changed to array [MI_MAX_AUDIO_PIDS]
|
std::vector<EPG_AUDIO_PIDS> audioPids; // available AudioPids, usually filled by VCR. Note: Vectors are easy to is also using the heap (memory fragmentation), might be changed to array [MI_MAX_AUDIO_PIDS]
|
||||||
|
|
||||||
uint64_t epgId; // currently not used, we just do not want to loose this info if movie info is saved backed
|
uint64_t epgId; // currently not used, we just do not want to loose this info if movie info is saved backed
|
||||||
uint64_t epgEpgId; // off_t currently not used, we just do not want to loose this info if movie info is saved backed
|
uint64_t epgEpgId; // off_t currently not used, we just do not want to loose this info if movie info is saved backed
|
||||||
int epgMode; // currently not used, we just do not want to loose this info if movie info is saved backed
|
int epgMode; // currently not used, we just do not want to loose this info if movie info is saved backed
|
||||||
int epgVideoPid; // currently not used, we just do not want to loose this info if movie info is saved backed
|
int epgVideoPid; // currently not used, we just do not want to loose this info if movie info is saved backed
|
||||||
int VideoType;
|
int VideoType;
|
||||||
int epgVTXPID; // currently not used, we just do not want to loose this info if movie info is saved backed
|
int epgVTXPID; // currently not used, we just do not want to loose this info if movie info is saved backed
|
||||||
bool marked;
|
|
||||||
bool delAsk;
|
|
||||||
std::string tfile; // thumbnail/cover file name
|
|
||||||
std::string ytdate; // yt published
|
|
||||||
std::string ytid; // yt published
|
|
||||||
int ytitag; // youtube quality profile
|
|
||||||
|
|
||||||
enum miSource { UNKNOWN = 0, YT, NK };
|
bool marked;
|
||||||
miSource source;
|
bool delAsk;
|
||||||
|
|
||||||
void clear(void);
|
std::string tfile; // thumbnail/cover file name
|
||||||
MI_MOVIE_INFO() { clear(); }
|
|
||||||
|
std::string ytdate; // youtube published
|
||||||
|
std::string ytid; // youtube published
|
||||||
|
int ytitag; // youtube quality profile
|
||||||
|
|
||||||
|
enum miSource {
|
||||||
|
UNKNOWN = 0,
|
||||||
|
YT,
|
||||||
|
NK
|
||||||
|
};
|
||||||
|
miSource source;
|
||||||
|
|
||||||
|
void clear(void);
|
||||||
|
MI_MOVIE_INFO() { clear(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<MI_MOVIE_INFO> MI_MOVIE_LIST;
|
typedef std::vector<MI_MOVIE_INFO> MI_MOVIE_LIST;
|
||||||
@@ -198,23 +172,16 @@ class CMovieInfo
|
|||||||
public: // Functions
|
public: // Functions
|
||||||
CMovieInfo();
|
CMovieInfo();
|
||||||
~CMovieInfo();
|
~CMovieInfo();
|
||||||
bool convertTs2XmlName(std::string& filename); // convert a ts file name in .xml file name
|
bool convertTs2XmlName(std::string &filename); // convert a ts file name in .xml file name
|
||||||
bool loadMovieInfo(MI_MOVIE_INFO* movie_info, CFile* file = NULL ); // load movie information for the given .xml filename. If there is no filename, the filename (ts) from movie_info is converted to xml and used instead
|
bool loadMovieInfo(MI_MOVIE_INFO *movie_info, CFile *file = NULL ); // load movie information for the given .xml filename. If there is no filename, the filename (ts) from movie_info is converted to xml and used instead
|
||||||
bool encodeMovieInfoXml(std::string* extMessage, MI_MOVIE_INFO * movie_info); // encode the movie_info structure to xml string
|
bool encodeMovieInfoXml(std::string *extMessage, MI_MOVIE_INFO *movie_info); // encode the movie_info structure to xml string
|
||||||
bool saveMovieInfo(MI_MOVIE_INFO& movie_info, CFile* file = NULL ); // encode the movie_info structure to xml and save it to the given .xml filename. If there is no filename, the filename (ts) from movie_info is converted to xml and used instead
|
bool saveMovieInfo(MI_MOVIE_INFO &movie_info, CFile *file = NULL ); // encode the movie_info structure to xml and save it to the given .xml filename. If there is no filename, the filename (ts) from movie_info is converted to xml and used instead
|
||||||
#if 0
|
bool addNewBookmark(MI_MOVIE_INFO *movie_info, MI_BOOKMARK &new_bookmark); // add a new bookmark to the given movie info. If there is no space false is returned
|
||||||
void showMovieInfo(MI_MOVIE_INFO& movie_info); // open a Hintbox and show the movie info
|
|
||||||
#endif
|
private: // Functions
|
||||||
void printDebugMovieInfo(MI_MOVIE_INFO& movie_info); // print movie info on debug channel (RS232)
|
bool parseXmlTree(std::string &text, MI_MOVIE_INFO *movie_info);
|
||||||
bool addNewBookmark(MI_MOVIE_INFO* movie_info,MI_BOOKMARK &new_bookmark); // add a new bookmark to the given movie info. If there is no space false is returned
|
bool loadFile(CFile &file, std::string &buffer);
|
||||||
|
bool saveFile(const CFile &file, std::string &buffer);
|
||||||
private:// Functions
|
|
||||||
bool parseXmlTree (std::string &text, MI_MOVIE_INFO* movie_info); // this is the 'good' function, but it needs the xmllib which is not currently linked within neutrino. Might be to slow as well. If used, add bookmark parsing
|
|
||||||
bool parseXmlQuickFix(std::string &text, MI_MOVIE_INFO* movie_info); // OK, this is very quick an dirty. It does not waste execution time or flash (this is QUICK). But, do not play to much with the xml files (e.g. with MS Notepad) since small changes in the structure could cause the parser to fail (this it DIRTY).
|
|
||||||
bool loadFile(CFile& file, std::string &buffer);
|
|
||||||
bool saveFile(const CFile& file, std::string &buffer);
|
|
||||||
private:// variables
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*MOVIEINFO_H_*/
|
#endif /*MOVIEINFO_H_*/
|
||||||
// vim:ts=4
|
|
||||||
|
Reference in New Issue
Block a user