gui/movieinfo: minor simplifications

Conflicts:
	src/gui/movieinfo.cpp
This commit is contained in:
martii
2014-04-21 08:41:28 +02:00
committed by [CST] Focus
parent 34d642a631
commit 7cd3a92e10
7 changed files with 141 additions and 251 deletions

View File

@@ -1524,6 +1524,7 @@ moviebrowser.hint_newbook_backward Neue Wiederholung\n 'blue' für Endposition
moviebrowser.hint_newbook_forward Neuer Werbesprung\n 'blue' für Endposition moviebrowser.hint_newbook_forward Neuer Werbesprung\n 'blue' für Endposition
moviebrowser.info_audio Audio moviebrowser.info_audio Audio
moviebrowser.info_channel Kanal moviebrowser.info_channel Kanal
moviebrowser.info_file Datei
moviebrowser.info_filename Name moviebrowser.info_filename Name
moviebrowser.info_genre_major Genre moviebrowser.info_genre_major Genre
moviebrowser.info_genre_minor Genre moviebrowser.info_genre_minor Genre
@@ -2172,6 +2173,7 @@ unicable.lnb Unicable Eingang
unicable.qrg Unicable Frequenz unicable.qrg Unicable Frequenz
unicable.scr Unicable SCR unicable.scr Unicable SCR
unit.decimal , unit.decimal ,
unit.long.years Jahre
unit.short.hour h unit.short.hour h
unit.short.millisecond ms unit.short.millisecond ms
unit.short.minute min unit.short.minute min

View File

@@ -1524,6 +1524,7 @@ moviebrowser.hint_newbook_backward New jump back\n 'blue' for endposition
moviebrowser.hint_newbook_forward New jump forward\n 'blue' for endposition moviebrowser.hint_newbook_forward New jump forward\n 'blue' for endposition
moviebrowser.info_audio Audio moviebrowser.info_audio Audio
moviebrowser.info_channel Channel moviebrowser.info_channel Channel
moviebrowser.info_file File
moviebrowser.info_filename Name moviebrowser.info_filename Name
moviebrowser.info_genre_major Genre moviebrowser.info_genre_major Genre
moviebrowser.info_genre_minor Genre moviebrowser.info_genre_minor Genre
@@ -2168,6 +2169,7 @@ unicable.lnb Unicable Input
unicable.qrg Unicable Frequency unicable.qrg Unicable Frequency
unicable.scr Unicable SCR unicable.scr Unicable SCR
unit.decimal . unit.decimal .
unit.long.years years
unit.short.hour h unit.short.hour h
unit.short.millisecond ms unit.short.millisecond ms
unit.short.minute min unit.short.minute min

View File

@@ -5040,3 +5040,5 @@ ret_err:
g_RCInput->postMsg(CRCInput::RC_home, 0); g_RCInput->postMsg(CRCInput::RC_home, 0);
return retval; return retval;
} }
// vim:ts=4

View File

@@ -52,6 +52,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <gui/widget/msgbox.h> #include <gui/widget/msgbox.h>
#include <gui/movieinfo.h> #include <gui/movieinfo.h>
#include <system/helpers.h>
#include <neutrino.h> #include <neutrino.h>
@@ -61,7 +62,6 @@
#include <xmltree/xmltok.h> #include <xmltree/xmltok.h>
#endif #endif
#define TRACE printf #define TRACE printf
#define VLC_URI "vlc://"
/************************************************************************ /************************************************************************
@@ -94,62 +94,70 @@ bool CMovieInfo::convertTs2XmlName(std::string& filename)
/************************************************************************ /************************************************************************
************************************************************************/ ************************************************************************/
#define XML_ADD_TAG_STRING(_xml_text_,_tag_name_,_tag_content_){ \ static void XML_ADD_TAG_STRING(std::string &_xml_text_, const char *_tag_name_, std::string _tag_content_)
_xml_text_ += "\t\t<" _tag_name_ ">"; \ {
_xml_text_ += ZapitTools::UTF8_to_UTF8XML(_tag_content_.c_str()); \ _xml_text_ += "\t\t<";
_xml_text_ += "</" _tag_name_ ">\n";} _xml_text_ += _tag_name_;
_xml_text_ += ">";
_xml_text_ += ZapitTools::UTF8_to_UTF8XML(_tag_content_.c_str());
_xml_text_ += "</";
_xml_text_ += _tag_name_;
_xml_text_ += ">\n";
}
#define XML_ADD_TAG_UNSIGNED(_xml_text_,_tag_name_,_tag_content_){\ static void XML_ADD_TAG_UNSIGNED(std::string &_xml_text_, const char *_tag_name_, unsigned int _tag_content_)
_xml_text_ += "\t\t<" _tag_name_ ">";\ {
char _tmp_[50];\ _xml_text_ += "\t\t<";
sprintf(_tmp_, "%u", (unsigned int) _tag_content_);\ _xml_text_ += _tag_name_;
_xml_text_ += _tmp_;\ _xml_text_ += ">";
_xml_text_ += "</" _tag_name_ ">\n";} _xml_text_ += to_string(_tag_content_);
_xml_text_ += "</";
_xml_text_ += _tag_name_;
_xml_text_ += ">\n";
}
#define XML_ADD_TAG_LONG(_xml_text_,_tag_name_,_tag_content_){\ static void XML_ADD_TAG_LONG(std::string &_xml_text_, const char *_tag_name_, long int _tag_content_)
_xml_text_ += "\t\t<" _tag_name_ ">";\ {
char _tmp_[50];\ _xml_text_ += "\t\t<";
sprintf(_tmp_, "%" PRIu64 "", (uint64_t)_tag_content_);\ _xml_text_ += _tag_name_;
_xml_text_ += _tmp_;\ _xml_text_ += ">";\
_xml_text_ += "</" _tag_name_ ">\n";} _xml_text_ += to_string(_tag_content_);
_xml_text_ += "</";
_xml_text_ += _tag_name_;
_xml_text_ += ">\n";
}
#define XML_GET_DATA_STRING(_node_,_tag_,_string_dest_){\ #if 0
if(!strcmp(_node_->GetType(), _tag_))\ std::string decodeXmlSpecialChars(std::string s);
{\
if(_node_->GetData() != NULL)\
{\
_string_dest_ = decodeXmlSpecialChars(_node_->GetData());\
}\
}}
#define XML_GET_DATA_INT(_node_,_tag_,_int_dest_){\
if(!strcmp(_node_->GetType(), _tag_))\
{\
if(_node_->GetData() != NULL)\
{\
_int_dest_ = atoi(_node_->GetData());\
}\
}}
#define XML_GET_DATA_LONG(_node_,_tag_,_int_dest_){\ static void XML_GET_DATA_STRING(XMLTreeNode *_node_, const char *_tag_, std::string &_string_dest_)
if(!strcmp(_node_->GetType(), _tag_))\ {
{\ if(!strcmp(_node_->GetType(), _tag_) && _node_->GetData())
if(_node_->GetData() != NULL)\ _string_dest_ = decodeXmlSpecialChars(_node_->GetData());
{\ }
sscanf(_node_->GetData(), "%llu", &_int_dest_); \
}\ static void XML_GET_DATA_INT(XMLTreeNode *_node_, const char *_tag_, int _int_dest_)
}} {
//sscanf(_node_->GetData(), "%lld", &_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\r\n");
char tmp[40];
*extMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"; *extMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"
*extMessage += "<" MI_XML_TAG_NEUTRINO " commandversion=\"1\">\n"; "<" MI_XML_TAG_NEUTRINO " commandversion=\"1\">\n"
*extMessage += "\t<" MI_XML_TAG_RECORD " command=\""; "\t<" MI_XML_TAG_RECORD " command=\""
*extMessage += "record"; "record"
*extMessage += "\">\n"; "\">\n";
XML_ADD_TAG_STRING(*extMessage, MI_XML_TAG_CHANNELNAME, movie_info->epgChannel); XML_ADD_TAG_STRING(*extMessage, MI_XML_TAG_CHANNELNAME, movie_info->epgChannel);
XML_ADD_TAG_STRING(*extMessage, MI_XML_TAG_EPGTITLE, movie_info->epgTitle); XML_ADD_TAG_STRING(*extMessage, MI_XML_TAG_EPGTITLE, movie_info->epgTitle);
XML_ADD_TAG_LONG(*extMessage, MI_XML_TAG_ID, movie_info->epgId); XML_ADD_TAG_LONG(*extMessage, MI_XML_TAG_ID, movie_info->epgId);
@@ -160,23 +168,16 @@ bool CMovieInfo::encodeMovieInfoXml(std::string * extMessage, MI_MOVIE_INFO * mo
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" selected=\"";
//sprintf(tmp, "%u", movie_info->audioPids[0].epgAudioPid); //pids.APIDs[i].pid);
//*extMessage += tmp;
//*extMessage += "\">\n";
*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 "=\"";
sprintf(tmp, "%u", movie_info->audioPids[i].epgAudioPid); //pids.APIDs[i].pid); *extMessage += to_string(movie_info->audioPids[i].epgAudioPid);
*extMessage += tmp;
*extMessage += "\" " MI_XML_TAG_ATYPE "=\""; *extMessage += "\" " MI_XML_TAG_ATYPE "=\"";
sprintf(tmp, "%u", movie_info->audioPids[i].atype); //pids.APIDs[i].pid); *extMessage += to_string(movie_info->audioPids[i].atype);
*extMessage += tmp;
*extMessage += "\" " MI_XML_TAG_SELECTED "=\""; *extMessage += "\" " MI_XML_TAG_SELECTED "=\"";
sprintf(tmp, "%u", movie_info->audioPids[i].selected); //pids.APIDs[i].pid); *extMessage += to_string(movie_info->audioPids[i].selected);
*extMessage += tmp;
*extMessage += "\" " MI_XML_TAG_NAME "=\""; *extMessage += "\" " MI_XML_TAG_NAME "=\"";
*extMessage += ZapitTools::UTF8_to_UTF8XML(movie_info->audioPids[i].epgAudioPidName.c_str()); *extMessage += ZapitTools::UTF8_to_UTF8XML(movie_info->audioPids[i].epgAudioPidName.c_str());
*extMessage += "\"/>\n"; *extMessage += "\"/>\n";
@@ -195,8 +196,8 @@ bool CMovieInfo::encodeMovieInfoXml(std::string * extMessage, MI_MOVIE_INFO * mo
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_QUALITY, movie_info->quality); XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_QUALITY, movie_info->quality);
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_PARENTAL_LOCKAGE, movie_info->parentalLockAge); XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_PARENTAL_LOCKAGE, movie_info->parentalLockAge);
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_DATE_OF_LAST_PLAY, movie_info->dateOfLastPlay); XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_DATE_OF_LAST_PLAY, movie_info->dateOfLastPlay);
*extMessage += "\t\t<" MI_XML_TAG_BOOKMARK ">\n"; *extMessage += "\t\t<" MI_XML_TAG_BOOKMARK ">\n"
*extMessage += "\t"; "\t";
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_BOOKMARK_START, movie_info->bookmarks.start); XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_BOOKMARK_START, movie_info->bookmarks.start);
*extMessage += "\t"; *extMessage += "\t";
XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_BOOKMARK_END, movie_info->bookmarks.end); XML_ADD_TAG_UNSIGNED(*extMessage, MI_XML_TAG_BOOKMARK_END, movie_info->bookmarks.end);
@@ -206,22 +207,18 @@ bool CMovieInfo::encodeMovieInfoXml(std::string * extMessage, MI_MOVIE_INFO * mo
if (movie_info->bookmarks.user[i].pos != 0 || i == 0) { if (movie_info->bookmarks.user[i].pos != 0 || i == 0) {
// encode any valid book, at least 1 // encode any valid book, at least 1
*extMessage += "\t\t\t<" MI_XML_TAG_BOOKMARK_USER " " MI_XML_TAG_BOOKMARK_USER_POS "=\""; *extMessage += "\t\t\t<" MI_XML_TAG_BOOKMARK_USER " " MI_XML_TAG_BOOKMARK_USER_POS "=\"";
sprintf(tmp, "%d", movie_info->bookmarks.user[i].pos); //pids.APIDs[i].pid); *extMessage += to_string(movie_info->bookmarks.user[i].pos);
*extMessage += tmp;
*extMessage += "\" " MI_XML_TAG_BOOKMARK_USER_TYPE "=\""; *extMessage += "\" " MI_XML_TAG_BOOKMARK_USER_TYPE "=\"";
sprintf(tmp, "%d", movie_info->bookmarks.user[i].length); //pids.APIDs[i].pid); *extMessage += to_string(movie_info->bookmarks.user[i].length);
*extMessage += tmp;
*extMessage += "\" " MI_XML_TAG_BOOKMARK_USER_NAME "=\""; *extMessage += "\" " MI_XML_TAG_BOOKMARK_USER_NAME "=\"";
*extMessage += ZapitTools::UTF8_to_UTF8XML(movie_info->bookmarks.user[i].name.c_str()); *extMessage += ZapitTools::UTF8_to_UTF8XML(movie_info->bookmarks.user[i].name.c_str());
*extMessage += "\"/>\n"; *extMessage += "\"/>\n";
} }
} }
*extMessage += "\t\t</" MI_XML_TAG_BOOKMARK ">\n"; *extMessage += "\t\t</" MI_XML_TAG_BOOKMARK ">\n"
/*****************************************************/ "\t</" MI_XML_TAG_RECORD ">\n"
"</" MI_XML_TAG_NEUTRINO ">\n";
*extMessage += "\t</" MI_XML_TAG_RECORD ">\n";
*extMessage += "</" MI_XML_TAG_NEUTRINO ">\n";
return true; return true;
} }
@@ -246,7 +243,7 @@ bool CMovieInfo::saveMovieInfo(MI_MOVIE_INFO & movie_info, CFile * file)
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.c_str(), text.size()); // save result = saveFile(file_xml, text); // save
if (result == false) { if (result == false) {
TRACE("[mi] saveXml: save error\r\n"); TRACE("[mi] saveXml: save error\r\n");
} }
@@ -278,8 +275,8 @@ bool CMovieInfo::loadMovieInfo(MI_MOVIE_INFO * movie_info, CFile * file)
if (result == true) { if (result == true) {
// load xml file in buffer // load xml file in buffer
char text[6000]; std::string text;
result = loadFile(file_xml, text, 6000); result = loadFile(file_xml, text);
if (result == true) { if (result == true) {
#ifdef XMLTREE_LIB #ifdef XMLTREE_LIB
result = parseXmlTree(text, movie_info); result = parseXmlTree(text, movie_info);
@@ -398,65 +395,59 @@ bool CMovieInfo::parseXmlTree(char */*text*/, MI_MOVIE_INFO * /*movie_info*/)
************************************************************************/ ************************************************************************/
void CMovieInfo::showMovieInfo(MI_MOVIE_INFO & movie_info) void CMovieInfo::showMovieInfo(MI_MOVIE_INFO & movie_info)
{ {
std::string print_buffer; std::string print_buffer = movie_info.epgInfo1;
tm *date_tm;
char date_char[100];
// prepare print buffer
print_buffer = movie_info.epgInfo1;
print_buffer += "\n"; print_buffer += "\n";
print_buffer += movie_info.epgInfo2; print_buffer += movie_info.epgInfo2;
print_buffer += "\n";
if ( !movie_info.productionCountry.empty() || movie_info.productionDate != 0) { if ( !movie_info.productionCountry.empty() || movie_info.productionDate != 0) {
print_buffer += "\n";
print_buffer += movie_info.productionCountry; print_buffer += movie_info.productionCountry;
print_buffer += " "; print_buffer += to_string(movie_info.productionDate + 1900);
snprintf(date_char, 12, "%4d", movie_info.productionDate + 1900); print_buffer += "\n";
print_buffer += date_char;
} }
if (!movie_info.serieName.empty()) { if (!movie_info.serieName.empty()) {
print_buffer += "\n\n"; print_buffer += "\n";
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_SERIE); print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_SERIE);
print_buffer += ": "; print_buffer += ": ";
print_buffer += movie_info.serieName; print_buffer += movie_info.serieName;
print_buffer += "\n";
} }
if (!movie_info.epgChannel.empty()) { if (!movie_info.epgChannel.empty()) {
print_buffer += "\n\n"; print_buffer += "\n";
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_CHANNEL); print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_CHANNEL);
print_buffer += ": "; print_buffer += ": ";
print_buffer += movie_info.epgChannel; print_buffer += movie_info.epgChannel;
print_buffer += "\n";
} }
if (movie_info.quality != 0) { if (movie_info.quality != 0) {
print_buffer += "\n";
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_QUALITY); print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_QUALITY);
print_buffer += ": "; print_buffer += ": ";
snprintf(date_char, 12, "%2d", movie_info.quality); print_buffer += to_string(movie_info.quality);
print_buffer += date_char; print_buffer += "\n";
} }
if (movie_info.parentalLockAge != 0) { if (movie_info.parentalLockAge != 0) {
print_buffer += "\n";
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_PARENTAL_LOCKAGE); print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_PARENTAL_LOCKAGE);
print_buffer += ": "; print_buffer += ": ";
snprintf(date_char, 12, "%2d", movie_info.parentalLockAge); print_buffer += to_string(movie_info.parentalLockAge);
print_buffer += date_char; print_buffer += " ";
print_buffer += " Jahre"; print_buffer += g_Locale->getText(LOCALE_UNIT_LONG_YEARS);
print_buffer += "\n";
} }
if (movie_info.length != 0) { if (movie_info.length != 0) {
print_buffer += "\n";
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_LENGTH); print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_LENGTH);
print_buffer += ": "; print_buffer += ": ";
snprintf(date_char, 12, "%3d", movie_info.length); print_buffer += to_string(movie_info.length);
print_buffer += date_char; print_buffer += "\n";
} }
if ( !movie_info.audioPids.empty() ) { if ( !movie_info.audioPids.empty() ) {
print_buffer += "\n";
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_AUDIO); print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_AUDIO);
print_buffer += ": "; print_buffer += ": ";
for (unsigned int i = 0; i < movie_info.audioPids.size(); i++) { for (unsigned int i = 0; i < movie_info.audioPids.size(); i++) {
print_buffer += movie_info.audioPids[i].epgAudioPidName; if (i)
print_buffer += ", "; print_buffer += ", ";
print_buffer += movie_info.audioPids[i].epgAudioPidName;
} }
print_buffer.erase(print_buffer.size()-2); print_buffer += "\n";
} }
if (movie_info.genreMajor != 0) if (movie_info.genreMajor != 0)
{ {
@@ -470,35 +461,33 @@ void CMovieInfo::showMovieInfo(MI_MOVIE_INFO & movie_info)
} }
else else
locale_genre = LOCALE_GENRE_UNKNOWN; locale_genre = LOCALE_GENRE_UNKNOWN;
print_buffer += "\n";
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_GENRE_MAJOR); print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_GENRE_MAJOR);
print_buffer += ": "; print_buffer += ": ";
print_buffer += g_Locale->getText(locale_genre); print_buffer += g_Locale->getText(locale_genre);
print_buffer += "\n";
} }
print_buffer += "\n\n"; tm *date_tm = localtime(&movie_info.dateOfLastPlay);
print_buffer += "\n";
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_PREVPLAYDATE); print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_PREVPLAYDATE);
print_buffer += ": "; print_buffer += ": ";
date_tm = localtime(&movie_info.dateOfLastPlay); print_buffer += strftime("%F", date_tm);
snprintf(date_char, 12, "%02d.%02d.%04d", date_tm->tm_mday, date_tm->tm_mon + 1, date_tm->tm_year + 1900);
print_buffer += date_char;
print_buffer += "\n"; print_buffer += "\n";
date_tm = localtime(&movie_info.file.Time);
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_RECORDDATE); print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_RECORDDATE);
print_buffer += ": "; print_buffer += ": ";
date_tm = localtime(&movie_info.file.Time); print_buffer += strftime("%F", date_tm);
snprintf(date_char, 12, "%02d.%02d.%04d", date_tm->tm_mday, date_tm->tm_mon + 1, date_tm->tm_year + 1900);
print_buffer += date_char;
if (movie_info.file.Size != 0) {
print_buffer += "\n"; print_buffer += "\n";
if (movie_info.file.Size != 0) {
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_SIZE); print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_SIZE);
print_buffer += ": "; print_buffer += ": ";
//snprintf(date_char, 12,"%4llu",movie_info.file.Size>>20); print_buffer += to_string(movie_info.file.Size >> 20);
sprintf(date_char, "%" PRIu64 "", movie_info.file.Size >> 20);
print_buffer += date_char;
//print_buffer += "\n";
}
print_buffer += "\n"; print_buffer += "\n";
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_PATH); }
print_buffer += g_Locale->getText(LOCALE_MOVIEBROWSER_INFO_FILE);
print_buffer += ": "; print_buffer += ": ";
print_buffer += movie_info.file.Name; print_buffer += movie_info.file.Name;
print_buffer += "\n"; print_buffer += "\n";
@@ -564,7 +553,7 @@ void CMovieInfo::printDebugMovieInfo(MI_MOVIE_INFO & movie_info)
/************************************************************************ /************************************************************************
************************************************************************/ ************************************************************************/
int find_next_char(char to_find, 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) {
if (text[start_pos] == to_find) { if (text[start_pos] == to_find) {
@@ -633,14 +622,15 @@ std::string decodeXmlSpecialChars(std::string s)
/************************************************************************ /************************************************************************
************************************************************************/ ************************************************************************/
bool CMovieInfo::parseXmlQuickFix(char *text, MI_MOVIE_INFO * movie_info) bool CMovieInfo::parseXmlQuickFix(std::string &_text, MI_MOVIE_INFO * movie_info)
{ {
#ifndef XMLTREE_LIB #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;
int bytes = strlen(text); const char *text = _text.c_str();
int bytes = _text.length();
/** search ****/ /** search ****/
int pos = 0; int pos = 0;
@@ -678,7 +668,7 @@ bool CMovieInfo::parseXmlQuickFix(char *text, MI_MOVIE_INFO * movie_info)
pos += sizeof(MI_XML_TAG_AUDIO); pos += sizeof(MI_XML_TAG_AUDIO);
int pos2; int pos2;
char *ptr; const char *ptr;
pos2 = -1; pos2 = -1;
ptr = strstr(&text[pos], MI_XML_TAG_PID); ptr = strstr(&text[pos], MI_XML_TAG_PID);
@@ -872,8 +862,8 @@ void MI_MOVIE_INFO::clear(void)
quality = 0; // (3 stars: classics, 2 stars: very good, 1 star: good, 0 stars: OK) quality = 0; // (3 stars: classics, 2 stars: very good, 1 star: good, 0 stars: OK)
productionDate = 0; // (Year) years since 1900 productionDate = 0; // (Year) years since 1900
parentalLockAge = 0; // MI_PARENTAL_LOCKAGE (0,6,12,16,18) parentalLockAge = 0; // MI_PARENTAL_LOCKAGE (0,6,12,16,18)
format = 0; // MI_VIDEO_FORMAT(16:9, 4:3) // format = 0; // MI_VIDEO_FORMAT(16:9, 4:3)
audio = 0; // MI_AUDIO (AC3, Deutsch, Englisch) // audio = 0; // MI_AUDIO (AC3, Deutsch, Englisch)
epgId = 0; epgId = 0;
epgEpgId = 0; epgEpgId = 0;
@@ -908,18 +898,7 @@ void MI_MOVIE_INFO::clear(void)
/************************************************************************ /************************************************************************
************************************************************************/ ************************************************************************/
bool CMovieInfo::loadFile(CFile & file, char *buffer, int buffer_size) bool CMovieInfo::loadFile(CFile & file, std::string &buffer)
{
bool result = false;
if (strncmp(file.getFileName().c_str(), VLC_URI, strlen(VLC_URI)) == 0) {
result = loadFile_vlc(file, buffer, buffer_size);
} else {
result = loadFile_std(file, buffer, buffer_size);
}
return (result);
}
bool CMovieInfo::loadFile_std(CFile & file, char *buffer, int buffer_size)
{ {
bool result = true; bool result = true;
@@ -929,47 +908,33 @@ bool CMovieInfo::loadFile_std(CFile & file, char *buffer, int buffer_size)
TRACE("[mi] loadXml: cannot open (%s)\r\n", file.getFileName().c_str()); TRACE("[mi] loadXml: cannot open (%s)\r\n", file.getFileName().c_str());
return false; return false;
} }
//TRACE( "show_ts_info: File found (%s)\r\n" ,filename->c_str()); struct stat st;
// read file content to buffer if (fstat(fd, &st)) {
int bytes = read(fd, buffer, buffer_size - 1);
if (bytes <= 0) // cannot read file into buffer, return!!!!
{
TRACE("[mi] loadXml: cannot read (%s)\r\n", file.getFileName().c_str());
close(fd); close(fd);
return false; return false;
} }
close(fd); char buf[st.st_size];
buffer[bytes] = 0; // terminate string if (st.st_size != read(fd, buf, st.st_size)) {
return (result); TRACE("[mi] loadXml: cannot read (%s)\r\n", file.getFileName().c_str());
} result = false;
} else
buffer = std::string(buf, st.st_size);
bool CMovieInfo::loadFile_vlc(CFile & /*file*/, char */*buffer*/, int /*buffer_size*/) close(fd);
{
bool result = false; return result;
return (result);
} }
/************************************************************************ /************************************************************************
************************************************************************/ ************************************************************************/
bool CMovieInfo::saveFile(const CFile & file, const char *text, const int text_size) bool CMovieInfo::saveFile(const CFile & file, std::string &text)
{
bool result = false;
if (strncmp(file.getFileName().c_str(), VLC_URI, strlen(VLC_URI)) == 0) {
result = saveFile_vlc(file, text, text_size);
} else {
result = saveFile_std(file, text, text_size);
}
return (result);
}
bool CMovieInfo::saveFile_std(const CFile & file, const char *text, const int text_size)
{ {
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=*/ /*int nr=*/
write(fd, text, text_size); write(fd, text.c_str(), text.size());
//fdatasync(fd); //fdatasync(fd);
close(fd); close(fd);
result = true; result = true;
@@ -979,83 +944,3 @@ bool CMovieInfo::saveFile_std(const CFile & file, const char *text, const int te
} }
return (result); return (result);
} }
bool CMovieInfo::saveFile_vlc(const CFile & /*file*/, const char */*text*/, const int /*text_size*/)
{
bool result = false;
return (result);
}
/* char buf[2048];
int done;
do
{
unsigned int len=fread(buf, 1, sizeof(buf), in);
done=len<sizeof(buf);
if (!parser->Parse(buf, len, 1))
{
TRACE("parse error: %s at line %d \r\n", parser->ErrorString(parser->GetErrorCode()), parser->GetCurrentLineNumber());
fclose(in);
delete parser;
return (false);
}
} while (!done);
fclose(in);
*
* */
#if 0
MI_MOVIE_INFO& MI_MOVIE_INFO::operator=(const MI_MOVIE_INFO& src)
{
file.Name = src.file.Name;
file.Url = src.file.Url;
file.Size = src.file.Size;
file.Time = src.file.Time;
dateOfLastPlay = src.dateOfLastPlay;
dirItNr = src.dirItNr;
genreMajor = src.genreMajor;
genreMinor = src.genreMinor;
length = src.length;
quality = src.quality;
productionDate = src.productionDate;
parentalLockAge = src.parentalLockAge;
format = src.format;
audio = src.audio;
epgId = src.epgId;
epgEpgId = src.epgEpgId;
epgMode = src.epgMode;
epgVideoPid = src.epgVideoPid;
VideoType = src.VideoType;
epgVTXPID = src.epgVTXPID;
productionCountry = src.productionCountry;
epgTitle = src.epgTitle;
epgInfo1 = src.epgInfo1;
epgInfo2 = src.epgInfo2;
epgChannel = src.epgChannel;
serieName = src.serieName;
bookmarks.end = src.bookmarks.end;
bookmarks.start = src.bookmarks.start;
bookmarks.lastPlayStop = src.bookmarks.lastPlayStop;
for (unsigned int i = 0; i < MI_MOVIE_BOOK_USER_MAX; i++) {
bookmarks.user[i].pos = src.bookmarks.user[i].pos;
bookmarks.user[i].length = src.bookmarks.user[i].length;
bookmarks.user[i].name = src.bookmarks.user[i].name;
}
for (unsigned int i = 0; i < src.audioPids.size(); i++) {
EPG_AUDIO_PIDS audio_pids;
audio_pids.epgAudioPid = src.audioPids[i].epgAudioPid;
audio_pids.epgAudioPidName = src.audioPids[i].epgAudioPidName;
audio_pids.atype = src.audioPids[i].atype;
audioPids.push_back(audio_pids);
}
ytdate = src.ytdate;
ytid = src.ytid;
ytitag = src.ytitag;
return *this;
}
#endif

View File

@@ -163,8 +163,8 @@ class MI_MOVIE_INFO
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]
@@ -204,17 +204,12 @@ class CMovieInfo
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 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
private:// Functions private:// Functions
bool parseXmlTree (char* 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 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(char* text, MI_MOVIE_INFO* movie_info); // OK, this is very quick an dirty. It does not waist execution time nor 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 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_std(CFile& file,char* buffer, int buffer_size); bool loadFile(CFile& file, std::string &buffer);
bool loadFile_vlc(CFile& file,char* buffer, int buffer_size); bool saveFile(const CFile& file, std::string &buffer);
bool loadFile(CFile& file,char* buffer, int buffer_size);
bool saveFile_std(const CFile& file, const char* text, const int text_size);
bool saveFile_vlc(const CFile& file, const char* text, const int text_sizet);
bool saveFile(const CFile& file, const char* text, const int text_size);
//void CMovieInfo::strReplace(std::string& orig, const char* fstr, const std::string rstr);
private:// variables private:// variables
}; };
#endif /*MOVIEINFO_H_*/ #endif /*MOVIEINFO_H_*/
// vim:ts=4

View File

@@ -1551,6 +1551,7 @@ typedef enum
LOCALE_MOVIEBROWSER_HINT_NEWBOOK_FORWARD, LOCALE_MOVIEBROWSER_HINT_NEWBOOK_FORWARD,
LOCALE_MOVIEBROWSER_INFO_AUDIO, LOCALE_MOVIEBROWSER_INFO_AUDIO,
LOCALE_MOVIEBROWSER_INFO_CHANNEL, LOCALE_MOVIEBROWSER_INFO_CHANNEL,
LOCALE_MOVIEBROWSER_INFO_FILE,
LOCALE_MOVIEBROWSER_INFO_FILENAME, LOCALE_MOVIEBROWSER_INFO_FILENAME,
LOCALE_MOVIEBROWSER_INFO_GENRE_MAJOR, LOCALE_MOVIEBROWSER_INFO_GENRE_MAJOR,
LOCALE_MOVIEBROWSER_INFO_GENRE_MINOR, LOCALE_MOVIEBROWSER_INFO_GENRE_MINOR,
@@ -2195,6 +2196,7 @@ typedef enum
LOCALE_UNICABLE_QRG, LOCALE_UNICABLE_QRG,
LOCALE_UNICABLE_SCR, LOCALE_UNICABLE_SCR,
LOCALE_UNIT_DECIMAL, LOCALE_UNIT_DECIMAL,
LOCALE_UNIT_LONG_YEARS,
LOCALE_UNIT_SHORT_HOUR, LOCALE_UNIT_SHORT_HOUR,
LOCALE_UNIT_SHORT_MILLISECOND, LOCALE_UNIT_SHORT_MILLISECOND,
LOCALE_UNIT_SHORT_MINUTE, LOCALE_UNIT_SHORT_MINUTE,

View File

@@ -1551,6 +1551,7 @@ const char * locale_real_names[] =
"moviebrowser.hint_newbook_forward", "moviebrowser.hint_newbook_forward",
"moviebrowser.info_audio", "moviebrowser.info_audio",
"moviebrowser.info_channel", "moviebrowser.info_channel",
"moviebrowser.info_file",
"moviebrowser.info_filename", "moviebrowser.info_filename",
"moviebrowser.info_genre_major", "moviebrowser.info_genre_major",
"moviebrowser.info_genre_minor", "moviebrowser.info_genre_minor",
@@ -2195,6 +2196,7 @@ const char * locale_real_names[] =
"unicable.qrg", "unicable.qrg",
"unicable.scr", "unicable.scr",
"unit.decimal", "unit.decimal",
"unit.long.years",
"unit.short.hour", "unit.short.hour",
"unit.short.millisecond", "unit.short.millisecond",
"unit.short.minute", "unit.short.minute",