From 618fa78a5aeaa498c012bca5dd73006a4a2b1a35 Mon Sep 17 00:00:00 2001 From: satbaby Date: Fri, 2 Nov 2012 21:50:43 +0100 Subject: [PATCH 01/64] src/neutrino.cpp:timeshiftDir : fix autodelete --- src/neutrino.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 45feb2504..a8db601d1 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -547,7 +547,9 @@ int CNeutrinoApp::loadSetup(const char * fname) std::string filename = e->d_name; if ((filename.find("_temp.ts") == filename.size() - 8) || (filename.find("_temp.xml") == filename.size() - 9)) { - remove(filename.c_str()); + std::string timeshiftDir_filename= timeshiftDir; + timeshiftDir_filename+= "/" + filename; + remove(timeshiftDir_filename.c_str()); } } closedir(d); From c40361147d6ee09e2e405797d047aa9c7056c3f6 Mon Sep 17 00:00:00 2001 From: satbaby Date: Fri, 2 Nov 2012 22:00:01 +0100 Subject: [PATCH 02/64] src/gui/epgview.cpp:check res after exec --- src/gui/epgview.cpp | 22 ++++++++++++---------- src/gui/eventlist.cpp | 9 ++------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 074804dc5..cbe93956a 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -674,10 +674,10 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start if ( doLoop ) { - neutrino_msg_t msg; - neutrino_msg_data_t data; + neutrino_msg_t msg = 0; + neutrino_msg_data_t data = 0; - int scrollCount; + int scrollCount = 0; bool loop = true; @@ -849,14 +849,16 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start { if(!followlist.empty()){ hide(); - CNeutrinoEventList *ee; - ee = new CNeutrinoEventList; - ee->exec(channel_id, g_Locale->getText(LOCALE_EPGVIEWER_MORE_SCREENINGS_SHORT),"","",followlist); // UTF-8 + CNeutrinoEventList *ee = new CNeutrinoEventList; + res = ee->exec(channel_id, g_Locale->getText(LOCALE_EPGVIEWER_MORE_SCREENINGS_SHORT),"","",followlist); // UTF-8 delete ee; - - if (!bigFonts && g_settings.bigFonts) { - g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->setSize((int)(g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getSize() * BIG_FONT_FAKTOR)); - g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->setSize((int)(g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getSize() * BIG_FONT_FAKTOR)); + if (res == menu_return::RETURN_EXIT_ALL) + loop = false; + else { + if (!bigFonts && g_settings.bigFonts) { + g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->setSize((int)(g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->getSize() * BIG_FONT_FAKTOR)); + g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->setSize((int)(g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getSize() * BIG_FONT_FAKTOR)); + } } bigFonts = g_settings.bigFonts; show(channel_id,epgData.eventID,&epgData.epg_times.startzeit,false); diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 2175f3323..6a872a8ee 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -973,16 +973,11 @@ void CNeutrinoEventList::showFunctionBar (bool show, t_channel_id channel_id) int CEventListHandler::exec(CMenuTarget* parent, const std::string &/*actionkey*/) { int res = menu_return::RETURN_EXIT_ALL; - CNeutrinoEventList *e; - CChannelList *channelList; - - if (parent) { parent->hide(); } - e = new CNeutrinoEventList; - - channelList = CNeutrinoApp::getInstance()->channelList; + CNeutrinoEventList *e = new CNeutrinoEventList; + CChannelList *channelList = CNeutrinoApp::getInstance()->channelList; e->exec(CZapit::getInstance()->GetCurrentChannelID(), channelList->getActiveChannelName()); // UTF-8 delete e; From 27fe0fe6e06e861e10f442914c02c1d116945139 Mon Sep 17 00:00:00 2001 From: satbaby Date: Sat, 3 Nov 2012 11:20:15 +0100 Subject: [PATCH 03/64] src/gui/epgview.cpp:show always all screening --- src/gui/epgview.cpp | 20 +++++++++++++------- src/gui/epgview.h | 6 +++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index cbe93956a..88eb18ede 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -152,7 +152,7 @@ void CEpgData::start() toph = topboxheight; } -void CEpgData::addTextToArray(const std::string & text, bool screening) // UTF-8 +void CEpgData::addTextToArray(const std::string & text, int screening) // UTF-8 { //printf("line: >%s<\n", text.c_str() ); if (text==" ") @@ -170,7 +170,7 @@ void CEpgData::addTextToArray(const std::string & text, bool screening) // UTF-8 } } -void CEpgData::processTextToArray(std::string text, bool screening) // UTF-8 +void CEpgData::processTextToArray(std::string text, int screening) // UTF-8 { std::string aktLine = ""; std::string aktWord = ""; @@ -249,7 +249,6 @@ void CEpgData::showText( int startPos, int ypos ) if(epgText[i].second){ std::string::size_type pos1 = epgText[i].first.find_first_not_of(tok, 0); std::string::size_type pos2 = epgText[i].first.find_first_of(tok, pos1); - while( pos2 != string::npos || pos1 != string::npos ){ switch(count){ case 1: @@ -262,7 +261,7 @@ void CEpgData::showText( int startPos, int ypos ) offset += digi; break; } - g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->RenderString(sx+10+offset, y+medlineheight, ox- 15- 15, epgText[i].first.substr(pos1, pos2 - pos1), COL_MENUCONTENT, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->RenderString(sx+10+offset, y+medlineheight, ox- 15- 15, epgText[i].first.substr(pos1, pos2 - pos1), (epgText[i].second==2)? COL_MENUCONTENTINACTIVE: COL_MENUCONTENT, 0, true); // UTF-8 count++; pos1 = epgText[i].first.find_first_not_of(tok, pos2); pos2 = epgText[i].first.find_first_of(tok, pos1); @@ -270,8 +269,9 @@ void CEpgData::showText( int startPos, int ypos ) offset = 0; count = 0; } - else + else{ g_Font[( i< info1_lines ) ?SNeutrinoSettings::FONT_TYPE_EPG_INFO1:SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->RenderString(sx+10, y+medlineheight, ox- 15- 15, epgText[i].first, COL_MENUCONTENT, 0, true); // UTF-8 + } } int sbc = ((textSize - 1)/ medlinecount) + 1; @@ -1030,7 +1030,7 @@ bool CEpgData::hasFollowScreenings(const t_channel_id /*channel_id*/, const std: followlist.clear(); for (e = evtlist.begin(); e != evtlist.end(); ++e) { - if (e->startTime <= tmp_curent_zeit) + if (e->startTime == tmp_curent_zeit) continue; if (! e->eventID) continue; @@ -1047,6 +1047,7 @@ int CEpgData::FollowScreenings (const t_channel_id /*channel_id*/, const std::st struct tm *tmStartZeit; std::string screening_dates,screening_nodual; int count = 0; + int flag = 1; char tmpstr[256]={0}; screening_dates = screening_nodual = ""; @@ -1066,9 +1067,14 @@ int CEpgData::FollowScreenings (const t_channel_id /*channel_id*/, const std::st strftime(tmpstr, sizeof(tmpstr), ". %H:%M", tmStartZeit ); screening_dates += tmpstr; + if (e->startTime <= tmp_curent_zeit) + flag = 2; + else + flag = 1; + if (screening_dates != screening_nodual) { screening_nodual=screening_dates; - processTextToArray(screening_dates, true ); // UTF-8 + processTextToArray(screening_dates, flag ); // UTF-8 } } return count; diff --git a/src/gui/epgview.h b/src/gui/epgview.h index 7b051c024..c1a569735 100644 --- a/src/gui/epgview.h +++ b/src/gui/epgview.h @@ -73,7 +73,7 @@ class CEpgData int ox, oy, sx, sy, toph, sb; int emptyLineCount, info1_lines; int textCount; - typedef std::pair epg_pair; + typedef std::pair epg_pair; std::vector epgText; int topheight,topboxheight; int buttonheight,botboxheight; @@ -81,8 +81,8 @@ class CEpgData void GetEPGData(const t_channel_id channel_id, uint64_t id, time_t* startzeit, bool clear = true ); void GetPrevNextEPGData( uint64_t id, time_t* startzeit ); - void addTextToArray( const std::string & text, bool screening ); - void processTextToArray(std::string text, bool screening = false); + void addTextToArray( const std::string & text, int screening ); + void processTextToArray(std::string text, int screening = 0); void showText( int startPos, int ypos ); bool hasFollowScreenings(const t_channel_id channel_id, const std::string & title); int FollowScreenings(const t_channel_id channel_id, const std::string & title); From f4f954415b1227a9dba50e6ed98cedf4970fbbb7 Mon Sep 17 00:00:00 2001 From: micha-bbg Date: Sat, 3 Nov 2012 15:34:34 +0100 Subject: [PATCH 04/64] * Software Update with apply the settings (Part6) - Use identifier '#:' for config vars in settingsupdate.conf --- data/settingsupdate.conf | 4 ++-- src/gui/ext_update.cpp | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/data/settingsupdate.conf b/data/settingsupdate.conf index bae28ab75..795e0025b 100644 --- a/data/settingsupdate.conf +++ b/data/settingsupdate.conf @@ -1,6 +1,6 @@ # settings for logfile -Log=1 -LogFile=/tmp/update.log +#:Log=1 +#:LogFile=/tmp/update.log ## Mögliche Einträge: diff --git a/src/gui/ext_update.cpp b/src/gui/ext_update.cpp index 392819871..1b7afd219 100644 --- a/src/gui/ext_update.cpp +++ b/src/gui/ext_update.cpp @@ -385,7 +385,7 @@ bool CExtUpdate::copyFileList(const std::string & fileList, const std::string & bool CExtUpdate::findConfigEntry(std::string & line, std::string find) { - if (line.find(find + "=") == 0) { + if (line.find("#:" + find + "=") == 0) { size_t pos = line.find_first_of('='); line = line.substr(pos+1); line = trim(line); @@ -442,21 +442,20 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) size_t pos; while(fgets(buf, sizeof(buf), f1) != NULL) { std::string line = buf; - // remove comments line = trim(line); - if (line.find_first_of("#") == 0) + // remove comments + if (line.find_first_of("#") == 0) { + if (line.find_first_of(":") == 1) { // config vars + if (line.length() > 1) + readConfig(line); + } continue; + } pos = line.find_first_of("#"); if (pos != std::string::npos) { line = line.substr(0, pos); line = trim(line); } - // config vars - if (line.find_first_of("/+-~") != 0) { - if (line.length() > 1) - readConfig(line); - continue; - } // special folders else if ((line == "/") || (line == "/*") || (line == "/*.*") || (line.find("/dev") == 0) || (line.find("/proc") == 0) || (line.find("/sys") == 0) || (line.find("/mnt") == 0) || (line.find("/tmp") == 0)) { From 7a5f5e8220dd6cbfd72289224bdc324afd4df08e Mon Sep 17 00:00:00 2001 From: micha-bbg Date: Sat, 3 Nov 2012 15:40:35 +0100 Subject: [PATCH 05/64] * Software Update with apply the settings (Part7) - Clean osrelease at user defined kernelversion (THX snafed) --- src/gui/ext_update.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/ext_update.cpp b/src/gui/ext_update.cpp index 1b7afd219..d951bc5b8 100644 --- a/src/gui/ext_update.cpp +++ b/src/gui/ext_update.cpp @@ -185,8 +185,12 @@ bool CExtUpdate::writemtdExt() // get osrelease struct utsname uts_info; - if( uname(&uts_info) == 0 ) + if( uname(&uts_info) == 0 ) { osrelease = uts_info.release; + size_t pos = osrelease.find_first_of(" "); + if (pos != std::string::npos) + osrelease = osrelease.substr(0, pos); + } else return ErrorReset(0, "error no kernel info"); From 01d44a627219ab21deaa99ae1837c41fd692913a Mon Sep 17 00:00:00 2001 From: micha-bbg Date: Sat, 3 Nov 2012 16:05:35 +0100 Subject: [PATCH 06/64] * Software Update with apply the settings (Part8) - src/gui/ext_update.cpp: Use new instead of malloc --- src/gui/ext_update.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/ext_update.cpp b/src/gui/ext_update.cpp index d951bc5b8..6b6f911a8 100644 --- a/src/gui/ext_update.cpp +++ b/src/gui/ext_update.cpp @@ -63,7 +63,7 @@ CExtUpdate::CExtUpdate() mtdRamError = ""; mtdNumber = -1; MTDBufSize = 0xFFFF; - MTDBuf = (char*)malloc(MTDBufSize); + MTDBuf = new char[MTDBufSize]; backupList = CONFIGDIR "/settingsupdate.conf"; defaultBackup = CONFIGDIR; @@ -78,7 +78,7 @@ CExtUpdate::CExtUpdate() CExtUpdate::~CExtUpdate() { if (MTDBuf != NULL) - free(MTDBuf); + delete[] MTDBuf; if(FileHelpers) delete[] FileHelpers; } From 9cec234d736ae96523f577fcd9ce48132b734f87 Mon Sep 17 00:00:00 2001 From: satbaby Date: Sun, 4 Nov 2012 13:25:44 +0100 Subject: [PATCH 07/64] src/driver/record.cpp: -fix auto_delete --- src/driver/record.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/driver/record.cpp b/src/driver/record.cpp index b3edb2b47..ae2567723 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -231,9 +231,9 @@ bool CRecordInstance::Stop(bool remove_event) CCamManager::getInstance()->Stop(channel_id, CCamManager::RECORD); if((autoshift && g_settings.auto_delete) /* || autoshift_delete*/) { - snprintf(buf,sizeof(buf), "\"%s.ts\"", filename); - my_system("nice", "-n20", "rm", "-f", buf); - snprintf(buf,sizeof(buf), "%s.xml", filename); + snprintf(buf,sizeof(buf), "nice -n 20 rm -f \"%s.ts\" &", filename); + my_system("/bin/sh", "-c", buf); + snprintf(buf,sizeof(buf), "%s.xml", filename); //autoshift_delete = false; unlink(buf); } From 5e284c68c3abb396142a7cbea6957639ddca3fd5 Mon Sep 17 00:00:00 2001 From: satbaby Date: Sun, 4 Nov 2012 22:13:36 +0100 Subject: [PATCH 08/64] src/gui/epgview.cpp: further corrections for followlist --- src/gui/epgview.cpp | 32 +++++++++++++++++++------------- src/gui/epgview.h | 3 ++- src/gui/eventlist.cpp | 2 +- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 88eb18ede..c0d7750f8 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -446,12 +446,12 @@ static bool sortByDateTime (const CChannelEvent& a, const CChannelEvent& b) return a.startTime< b.startTime; } -int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_startzeit, bool doLoop ) +int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_startzeit, bool doLoop, bool callFromfollowlist ) { int res = menu_return::RETURN_REPAINT; static uint64_t id; static time_t startzeit; - + call_fromfollowlist = callFromfollowlist; if (a_startzeit) startzeit=*a_startzeit; id=a_id; @@ -660,13 +660,13 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start } GetPrevNextEPGData( epgData.eventID, &epgData.epg_times.startzeit ); - if (prev_id != 0) + if ((prev_id != 0) && !call_fromfollowlist) { frameBuffer->paintBoxRel(sx+ 5, sy+ oy- botboxheight+ 4, botboxheight- 8, botboxheight- 8, COL_MENUCONTENT_PLUS_3); g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->RenderString(sx+ 10, sy+ oy- 3, widthr, "<", COL_MENUCONTENT + 3); } - if (next_id != 0) + if ((next_id != 0) && !call_fromfollowlist) { frameBuffer->paintBoxRel(sx+ ox- botboxheight+ 8- 5, sy+ oy- botboxheight+ 4, botboxheight- 8, botboxheight- 8, COL_MENUCONTENT_PLUS_3); g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->RenderString(sx+ ox- botboxheight+ 8, sy+ oy- 3, widthr, ">", COL_MENUCONTENT + 3); @@ -717,7 +717,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start CNeutrinoApp::getInstance()->handleMsg(msg, data); break; case CRCInput::RC_left: - if (prev_id != 0) + if ((prev_id != 0) && !call_fromfollowlist) { frameBuffer->paintBoxRel(sx+ 5, sy+ oy- botboxheight+ 4, botboxheight- 8, botboxheight- 8, COL_MENUCONTENT_PLUS_1); g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->RenderString(sx+ 10, sy+ oy- 3, widthr, "<", COL_MENUCONTENT + 1); @@ -728,7 +728,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start break; case CRCInput::RC_right: - if (next_id != 0) + if ((next_id != 0) && !call_fromfollowlist) { frameBuffer->paintBoxRel(sx+ ox- botboxheight+ 8- 5, sy+ oy- botboxheight+ 4, botboxheight- 8, botboxheight- 8, COL_MENUCONTENT_PLUS_1); g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->RenderString(sx+ ox- botboxheight+ 8, sy+ oy- 3, widthr, ">", COL_MENUCONTENT + 1); @@ -847,8 +847,11 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start } case CRCInput::RC_blue: { - if(!followlist.empty()){ + if(!followlist.empty() && !call_fromfollowlist){ hide(); + time_t tmp_sZeit = epgData.epg_times.startzeit; + uint64_t tmp_eID = epgData.eventID; + CNeutrinoEventList *ee = new CNeutrinoEventList; res = ee->exec(channel_id, g_Locale->getText(LOCALE_EPGVIEWER_MORE_SCREENINGS_SHORT),"","",followlist); // UTF-8 delete ee; @@ -861,7 +864,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start } } bigFonts = g_settings.bigFonts; - show(channel_id,epgData.eventID,&epgData.epg_times.startzeit,false); + show(channel_id,tmp_eID,&tmp_sZeit,false); } break; } @@ -897,8 +900,10 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start break; case CRCInput::RC_favorites: case CRCInput::RC_sat: - g_RCInput->postMsg (msg, 0); - loop = false; + if( !call_fromfollowlist){ + g_RCInput->postMsg (msg, 0); + loop = false; + } break; default: @@ -1027,7 +1032,8 @@ void CEpgData::GetPrevNextEPGData( uint64_t id, time_t* startzeit ) bool CEpgData::hasFollowScreenings(const t_channel_id /*channel_id*/, const std::string &title) { CChannelEventList::iterator e; - followlist.clear(); + if(!followlist.empty()) + followlist.clear(); for (e = evtlist.begin(); e != evtlist.end(); ++e) { if (e->startTime == tmp_curent_zeit) @@ -1116,9 +1122,9 @@ void CEpgData::showTimerEventBar (bool pshow) frameBuffer->paintBoxRel(sx,y,ox,h, COL_INFOBAR_SHADOW_PLUS_1, RADIUS_LARGE, CORNER_BOTTOM);//round if (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) - ::paintButtons(x, y, 0, has_follow_screenings ? 3:2, EpgButtons, h); + ::paintButtons(x, y, 0, (has_follow_screenings && !call_fromfollowlist) ? 3:2, EpgButtons, h); else - ::paintButtons(x, y, 0, has_follow_screenings ? 2:1, &EpgButtons[1], h); + ::paintButtons(x, y, 0, (has_follow_screenings && !call_fromfollowlist) ? 2:1, &EpgButtons[1], h); #if 0 // Button: Timer Record & Channelswitch diff --git a/src/gui/epgview.h b/src/gui/epgview.h index c1a569735..7492a79b3 100644 --- a/src/gui/epgview.h +++ b/src/gui/epgview.h @@ -63,6 +63,7 @@ class CEpgData int epg_done; bool bigFonts; bool has_follow_screenings; + bool call_fromfollowlist; time_t tmp_curent_zeit; uint64_t prev_id; @@ -92,7 +93,7 @@ class CEpgData CEpgData(); void start( ); - int show(const t_channel_id channel_id, uint64_t id = 0, time_t* startzeit = NULL, bool doLoop = true ); + int show(const t_channel_id channel_id, uint64_t id = 0, time_t* startzeit = NULL, bool doLoop = true, bool callFromfollowlist = false ); void hide(); }; diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 6a872a8ee..936606b12 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -606,7 +606,7 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c hide(); //FIXME res = g_EpgData->show(evtlist[selected].sub ? GET_CHANNEL_ID_FROM_EVENT_ID(evtlist[selected].eventID) : channel_id, evtlist[selected].eventID, &evtlist[selected].startTime); - res = g_EpgData->show(evtlist[selected].channelID, evtlist[selected].eventID, &evtlist[selected].startTime); + res = g_EpgData->show(evtlist[selected].channelID, evtlist[selected].eventID, &evtlist[selected].startTime, true, showfollow ); if ( res == menu_return::RETURN_EXIT_ALL ) { loop = false; From 926e0ce1415277a0d686708e4085ac4f886e80f5 Mon Sep 17 00:00:00 2001 From: satbaby Date: Mon, 5 Nov 2012 09:24:51 +0100 Subject: [PATCH 09/64] initialize not initialized var --- src/gui/cec_setup.cpp | 2 ++ src/gui/infoviewer.cpp | 19 ++++++++++++++++++- src/gui/infoviewer_bb.cpp | 5 +++++ src/gui/widget/listframe.h | 2 -- src/gui/widget/msgbox.cpp | 2 ++ src/gui/widget/progresswindow.cpp | 4 ++++ src/gui/widget/stringinput_ext.h | 4 ++-- src/gui/widget/textbox.cpp | 5 +++++ src/gui/widget/textbox.h | 2 +- src/gui/zapit_setup.cpp | 2 ++ src/nhttpd/yhttpd_core/yconnection.cpp | 11 +++++++++++ src/nhttpd/yhttpd_core/yhook.h | 2 +- 12 files changed, 53 insertions(+), 7 deletions(-) diff --git a/src/gui/cec_setup.cpp b/src/gui/cec_setup.cpp index edc861b6b..65c10c9c1 100644 --- a/src/gui/cec_setup.cpp +++ b/src/gui/cec_setup.cpp @@ -52,6 +52,8 @@ extern cVideo *videoDecoder; CCECSetup::CCECSetup() { width = w_max (40, 10); //% + cec1 = NULL; + cec2 = NULL; } CCECSetup::~CCECSetup() diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index 17d7197df..e1292fd5d 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -90,7 +90,24 @@ CInfoViewer::CInfoViewer () timescale = NULL; frameBuffer = CFrameBuffer::getInstance(); infoViewerBB = CInfoViewerBB::getInstance(); - + InfoHeightY = 0; + ButtonWidth = 0; + rt_dx = 0; + rt_dy = 0; + ChanNameX = 0; + ChanNameY = 0; + ChanWidth = 0; + ChanHeight = 0; + time_left_width = 0; + time_dot_width = 0; + time_width = 0; + time_height = 0; + old_timestr[0] = 0; + lastsnr = 0; + lastsig = 0; + lasttime = 0; + aspectRatio = 0; + ChanInfoX = 0; Init(); infoViewerBB->Init(); } diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index 006a529b7..b6036c647 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -89,6 +89,11 @@ CInfoViewerBB::CInfoViewerBB() #endif hddperT = 0; hddperTflag = false; + bbIconInfo[0].x = 0; + bbIconInfo[0].h = 0; + BBarY = 0; + BBarFontY = 0; + Init(); } diff --git a/src/gui/widget/listframe.h b/src/gui/widget/listframe.h index 0f5a40195..ff457c8dd 100644 --- a/src/gui/widget/listframe.h +++ b/src/gui/widget/listframe.h @@ -96,7 +96,6 @@ class CListFrame int m_nNrOfPages; int m_nNrOfLines; int m_nNrOfRows; - int m_nMaxLineWidth; int m_nLinesPerPage; int m_nCurrentLine; int m_nCurrentPage; @@ -142,7 +141,6 @@ class CListFrame void paint(void); inline CBox getWindowsPos(void) {return(m_cFrame);}; -inline int getMaxLineWidth(void) {return(m_nMaxLineWidth);}; inline int getSelectedLine(void) {return(m_nSelectedLine);}; inline int getLines(void) {return(m_nNrOfLines);}; inline int getPages(void) {return(m_nNrOfPages);}; diff --git a/src/gui/widget/msgbox.cpp b/src/gui/widget/msgbox.cpp index 032b4877e..f1e5c06fe 100644 --- a/src/gui/widget/msgbox.cpp +++ b/src/gui/widget/msgbox.cpp @@ -213,6 +213,8 @@ CMsgBox::~CMsgBox() void CMsgBox::initVar(void) { //TRACE("->CMsgBox::InitVar\r\n"); + mode = AUTO_WIDTH; + m_nResult = mbrYes; m_cTitle = ""; m_cIcon = ""; m_nMode = SCROLL | TITLE | BORDER ; diff --git a/src/gui/widget/progresswindow.cpp b/src/gui/widget/progresswindow.cpp index c5267ae64..fa8dff4e4 100644 --- a/src/gui/widget/progresswindow.cpp +++ b/src/gui/widget/progresswindow.cpp @@ -49,6 +49,10 @@ CProgressWindow::CProgressWindow() global_progress = local_progress = 101; statusText = ""; + globalstatusX = 0; + globalstatusY = 0; + localstatusY = 0; + statusTextY = 0; x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width ) >> 1 ); y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height) >>1 ); diff --git a/src/gui/widget/stringinput_ext.h b/src/gui/widget/stringinput_ext.h index 22ed53bb5..af11089f1 100644 --- a/src/gui/widget/stringinput_ext.h +++ b/src/gui/widget/stringinput_ext.h @@ -108,7 +108,7 @@ class CExtendedInput_Item_Spacer : public CExtendedInput_Item int mSpacingX; int mSpacingY; public: - CExtendedInput_Item_Spacer(){}; + CExtendedInput_Item_Spacer(){mSpacingY = 0;mSpacingX = 0;}; CExtendedInput_Item_Spacer(int spaceX, int spaceY=0){mSpacingX=spaceX;mSpacingY=spaceY;}; virtual void init(int &x, int &y){x+=mSpacingX;y+=mSpacingY;}; virtual bool isSelectable(){return false;}; @@ -119,7 +119,7 @@ class CExtendedInput_Item_newLiner : public CExtendedInput_Item protected: int mSpacingY; public: - CExtendedInput_Item_newLiner(){}; + CExtendedInput_Item_newLiner(){mSpacingY=0;}; CExtendedInput_Item_newLiner(int spaceY){mSpacingY=spaceY;}; virtual void init(int &x, int &y){x=0;y+=mSpacingY;}; virtual bool isSelectable(){return false;}; diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 3bab0f7ce..7c25463f7 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -152,6 +152,11 @@ CTextBox::~CTextBox() void CTextBox::initVar(void) { //TRACE("[CTextBox]->InitVar\r\n"); + m_showTextFrame = 0; + m_nNrOfNewLine = 0; + m_nMaxLineWidth = 0; + max_width = 0; + m_cText = ""; m_nMode = SCROLL; diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index a308d05f9..c57a27419 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -72,7 +72,7 @@ class CBox public: /* Constructor */ - inline CBox(){;}; + inline CBox(){iY = 0; iX = 0; iWidth = 0;iHeight = 0;}; inline CBox( const int _iX, const int _iY, const int _iWidth, const int _iHeight){iX=_iX; iY=_iY; iWidth=_iWidth; iHeight=_iHeight;}; inline ~CBox(){;}; /* Functions */ diff --git a/src/gui/zapit_setup.cpp b/src/gui/zapit_setup.cpp index f8e18168c..6a68b0704 100644 --- a/src/gui/zapit_setup.cpp +++ b/src/gui/zapit_setup.cpp @@ -39,6 +39,8 @@ CZapitSetup::CZapitSetup() { + zapit1 = NULL; + zapit2 = NULL; width = w_max (40, 10); //% } diff --git a/src/nhttpd/yhttpd_core/yconnection.cpp b/src/nhttpd/yhttpd_core/yconnection.cpp index e41b7d3e3..7c035c12d 100644 --- a/src/nhttpd/yhttpd_core/yconnection.cpp +++ b/src/nhttpd/yhttpd_core/yconnection.cpp @@ -22,6 +22,11 @@ long CWebserverConnection::GConnectionNumber = 0; // Constructor & Destructor & Initialization //============================================================================= CWebserverConnection::CWebserverConnection(CWebserver *pWebserver) { + sock = 0; + ConnectionNumber = 0; + enlapsed_request = 0; + enlapsed_response = 0; + Webserver = pWebserver; Request.Webserver = pWebserver; Request.Connection = this; @@ -39,6 +44,12 @@ CWebserverConnection::CWebserverConnection(CWebserver *pWebserver) { //------------------------------------------------------------------------- CWebserverConnection::CWebserverConnection() { // aprintf("test CWebserverConnection::CWebserverConnection()\n"); + sock = 0; + RequestCanceled = 0; + keep_alive = 0; + HttpStatus = 0; + enlapsed_request = 0; + enlapsed_response = 0; ConnectionNumber = ++GConnectionNumber; } //------------------------------------------------------------------------- diff --git a/src/nhttpd/yhttpd_core/yhook.h b/src/nhttpd/yhttpd_core/yhook.h index 3c0306811..9556be9f5 100644 --- a/src/nhttpd/yhttpd_core/yhook.h +++ b/src/nhttpd/yhttpd_core/yhook.h @@ -141,7 +141,7 @@ public: CStringList HookVarList; // Variables in Hook-Handling passing to other Hooks THttp_Method Method; // HTTP Method (requested) // constructor & deconstructor - CyhookHandler(){}; + CyhookHandler(){ContentLength = 0; keep_alive = 0; _outIndent = 0;}; virtual ~CyhookHandler(){}; // hook slot handler From b6535a4823982ceec885ab0e3b3a1bab10a17e07 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Mon, 5 Nov 2012 14:06:24 +0100 Subject: [PATCH 10/64] - satellites.xml: update astra 19.2 --- data/satellites.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/data/satellites.xml b/data/satellites.xml index 66bad02de..739e4d754 100755 --- a/data/satellites.xml +++ b/data/satellites.xml @@ -1572,6 +1572,7 @@ + From 80fe0c93076686ee221b5aebc54a027f4f62daaa Mon Sep 17 00:00:00 2001 From: satbaby Date: Mon, 5 Nov 2012 16:45:34 +0100 Subject: [PATCH 11/64] src/gui/bouquetlist.cpp: close FAV window with rc-fav only in FAV mode --- src/gui/bouquetlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index 8395499ab..a3fefe005 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -384,7 +384,7 @@ int CBouquetList::show(bool bShowChannelList) } else if ((msg == CRCInput::RC_timeout ) || (msg == (neutrino_msg_t)g_settings.key_channelList_cancel) || - (msg == CRCInput::RC_favorites) ) + ((msg == CRCInput::RC_favorites) && (CNeutrinoApp::getInstance()->GetChannelMode() == LIST_MODE_FAV))) { selected = oldselected; if(fader.StartFadeOut()) { From 4e3791be7231fa524fb27b734d37a40296d000e3 Mon Sep 17 00:00:00 2001 From: satbaby Date: Mon, 5 Nov 2012 16:48:41 +0100 Subject: [PATCH 12/64] src/driver/streamts.cpp: use new instead of malloc --- src/driver/streamts.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/driver/streamts.cpp b/src/driver/streamts.cpp index ec2633bc0..afeebd388 100644 --- a/src/driver/streamts.cpp +++ b/src/driver/streamts.cpp @@ -259,11 +259,10 @@ void * streamts_live_thread(void *data) char cbuf[512]; char *bp; int fd = (int) data; - FILE * fp; unsigned char demuxfd_count = 0; printf("Starting LIVE STREAM thread, fd %d\n", fd); - fp = fdopen(fd, "r+"); + FILE * fp = fdopen(fd, "r+"); if(fp == NULL) { perror("fdopen"); return 0; @@ -323,9 +322,9 @@ void * streamts_live_thread(void *data) pids[demuxfd_count++] = channel->getAudioChannel(i)->pid; } - buf = (unsigned char *) malloc(IN_SIZE); + buf = new unsigned char [IN_SIZE]; if (buf == NULL) { - perror("malloc"); + perror("NEW"); return 0; } @@ -353,7 +352,7 @@ void * streamts_live_thread(void *data) CCamManager::getInstance()->Stop(CZapit::getInstance()->GetCurrentChannelID(), CCamManager::STREAM); delete dmx; - free(buf); + delete []buf; close(fd); return 0; } From 69c22d15949e77068debd9720d69b48cf4f8487e Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 27 Aug 2012 15:14:16 +0200 Subject: [PATCH 13/64] *CTextBox: remove printf it' makes osd too slow --- src/gui/widget/textbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 7c25463f7..18a39ebb5 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -222,7 +222,7 @@ void CTextBox::reSizeMainFrameWidth(int textWidth) void CTextBox::reSizeMainFrameHeight(int textHeight) { - TRACE("[CTextBox]->ReSizeMainFrameHeight: %d, current: %d\r\n",textHeight,m_cFrameTextRel.iHeight); + //TRACE("[CTextBox]->ReSizeMainFrameHeight: %d, current: %d\r\n",textHeight,m_cFrameTextRel.iHeight); int iNewWindowHeight = textHeight + 2*text_border_width; From 12e778773bdb6ae2b8875f7bc7ea23886c4d5791 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 28 Aug 2012 19:36:08 +0200 Subject: [PATCH 14/64] *user_menu: personalize also yellow and green buttons --- src/gui/personalize.cpp | 23 ++++++++++++++++------- src/gui/personalize.h | 7 +++++-- src/neutrino.cpp | 27 +++++++++++++++++++++++++++ src/system/settings.cpp | 2 ++ src/system/settings.h | 8 +++++--- 5 files changed, 55 insertions(+), 12 deletions(-) diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp index 2b089178a..d42abf8f9 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -396,9 +396,14 @@ void CPersonalizeGui::ShowUserMenu(CMenuWidget* p_widget, vectoraddItem(new CMenuOptionChooser(usermenu[0].menue_title, &g_settings.personalize[SNeutrinoSettings::P_MAIN_RED_BUTTON], PERSONALIZE_ACTIVE_MODE_OPTIONS, PERSONALIZE_ACTIVE_MODE_MAX, true, user_menu_notifier));/*LOCALE_INFOVIEWER_EVENTLIST*/ + //green + p_widget->addItem(new CMenuOptionChooser(usermenu[1].menue_title, &g_settings.personalize[SNeutrinoSettings::P_MAIN_GREEN_BUTTON], PERSONALIZE_ACTIVE_MODE_OPTIONS, PERSONALIZE_ACTIVE_MODE_MAX, true, user_menu_notifier)); + //yellow + p_widget->addItem(new CMenuOptionChooser(usermenu[2].menue_title, &g_settings.personalize[SNeutrinoSettings::P_MAIN_YELLOW_BUTTON], PERSONALIZE_ACTIVE_MODE_OPTIONS, PERSONALIZE_ACTIVE_MODE_MAX, true, user_menu_notifier)); //blue p_widget->addItem(new CMenuOptionChooser(usermenu[3].menue_title, &g_settings.personalize[SNeutrinoSettings::P_MAIN_BLUE_BUTTON], PERSONALIZE_ACTIVE_MODE_OPTIONS, PERSONALIZE_ACTIVE_MODE_MAX, true, user_menu_notifier));/*LOCALE_INFOVIEWER_STREAMINFO*/ @@ -901,18 +906,22 @@ void CPersonalizeGui::restoreSettings() //helper class to enable/disable some items in usermenu setup -CUserMenuNotifier::CUserMenuNotifier( CMenuItem* i1, CMenuItem* i2) +CUserMenuNotifier::CUserMenuNotifier( CMenuItem* i1, CMenuItem* i2, CMenuItem *i3, CMenuItem *i4) { - toDisable[0]=i1; - toDisable[1]=i2; + toDisable[0]=i1; + toDisable[1]=i2; + toDisable[2]=i3; + toDisable[3]=i4; } bool CUserMenuNotifier::changeNotify(const neutrino_locale_t, void *) { toDisable[0]->setActive(g_settings.personalize[SNeutrinoSettings::P_MAIN_RED_BUTTON]); - toDisable[1]->setActive(g_settings.personalize[SNeutrinoSettings::P_MAIN_BLUE_BUTTON]); - - return false; + toDisable[1]->setActive(g_settings.personalize[SNeutrinoSettings::P_MAIN_GREEN_BUTTON]); + toDisable[2]->setActive(g_settings.personalize[SNeutrinoSettings::P_MAIN_YELLOW_BUTTON]); + toDisable[3]->setActive(g_settings.personalize[SNeutrinoSettings::P_MAIN_BLUE_BUTTON]); + + return false; } //helper class to enable/disable pin setup diff --git a/src/gui/personalize.h b/src/gui/personalize.h index c9c7b4c2e..b3c00ea97 100644 --- a/src/gui/personalize.h +++ b/src/gui/personalize.h @@ -68,9 +68,12 @@ extern CPlugins * g_PluginList; /* neutrino.cpp */ class CUserMenuNotifier : public CChangeObserver { private: - CMenuItem* toDisable[2]; + + CMenuItem* toDisable[4]; + public: - CUserMenuNotifier( CMenuItem*, CMenuItem*); + CUserMenuNotifier( CMenuItem*, CMenuItem*, CMenuItem*, CMenuItem*); + bool changeNotify(const neutrino_locale_t = NONEXISTANT_LOCALE, void *data = NULL); }; diff --git a/src/neutrino.cpp b/src/neutrino.cpp index a8db601d1..42919c114 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2117,6 +2117,33 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) else ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); } + else if ((msg == CRCInput::RC_audio) && !g_settings.audio_run_player) + { + StopSubtitles(); + usermenu.showUserMenu(SNeutrinoSettings::BUTTON_GREEN); + StartSubtitles(); + } + else if( msg == CRCInput::RC_green) + { + if (g_settings.personalize[SNeutrinoSettings::P_MAIN_GREEN_BUTTON] == CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED) + { + StopSubtitles(); + usermenu.showUserMenu(SNeutrinoSettings::BUTTON_GREEN); + StartSubtitles(); + } + else + ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); + } + else if( msg == CRCInput::RC_yellow ) { // NVODs + if (g_settings.personalize[SNeutrinoSettings::P_MAIN_YELLOW_BUTTON] == CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED) + { + StopSubtitles(); + usermenu.showUserMenu(SNeutrinoSettings::BUTTON_YELLOW); + StartSubtitles(); + } + else + ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); + } else if( (msg == CRCInput::RC_green) || ((msg == CRCInput::RC_audio) && !g_settings.audio_run_player) ) { StopSubtitles(); diff --git a/src/system/settings.cpp b/src/system/settings.cpp index 15c32b6cb..d9d45c3e9 100644 --- a/src/system/settings.cpp +++ b/src/system/settings.cpp @@ -35,6 +35,8 @@ const struct personalize_settings_t personalize_settings[SNeutrinoSettings::P_SE //user menu {"personalize_bluebutton" , CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED}, // features + {"personalize_yellowbutton" , CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED}, // features + {"personalize_greenbutton" , CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED}, // features {"personalize_redbutton" , CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED}, // epg/info //main menu diff --git a/src/system/settings.h b/src/system/settings.h index 84f3f4bca..cbb7b0c25 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -142,9 +142,11 @@ struct SNeutrinoSettings //user menu P_MAIN_BLUE_BUTTON, - P_MAIN_RED_BUTTON, - - //main menu + P_MAIN_YELLOW_BUTTON, + P_MAIN_GREEN_BUTTON, + P_MAIN_RED_BUTTON, + + //main menu P_MAIN_TV_MODE, P_MAIN_TV_RADIO_MODE, //togglemode P_MAIN_RADIO_MODE, From da63457eef33051ddbe58fe2b46efc4f00b4e6d7 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 30 Aug 2012 21:22:49 +0200 Subject: [PATCH 15/64] *CMovieBrowser: set button yes in message box as default on delete ts file --- src/gui/moviebrowser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index b651122ee..2a5a3a2c7 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -1631,7 +1631,7 @@ void CMovieBrowser::refreshFoot(void) m_pcFontFoot->RenderString(m_cBoxFrame.iX+xpos1+width*2 + 10 + iw, m_cBoxFrame.iY+m_cBoxFrameFootRel.iY + m_cBoxFrameFootRel.iHeight + 4 , width-30, ok_text.c_str(), (CFBWindow::color_t)color, 0, true); // UTF-8 if (IsRecord == false) { - //delte icon + //delete icon m_pcWindow->getIconSize(NEUTRINO_ICON_BUTTON_MUTE_SMALL, &iw, &ih); m_pcWindow->paintIcon(NEUTRINO_ICON_BUTTON_MUTE_SMALL, m_cBoxFrame.iX+xpos1+width*3, m_cBoxFrame.iY+m_cBoxFrameFootRel.iY, m_cBoxFrameFootRel.iHeight+ 6); m_pcFontFoot->RenderString(m_cBoxFrame.iX+xpos1+width*3 + 10 + iw , m_cBoxFrame.iY+m_cBoxFrameFootRel.iY + m_cBoxFrameFootRel.iHeight + 4 , width-30, g_Locale->getText(LOCALE_FILEBROWSER_DELETE), (CFBWindow::color_t)color, 0, true); // UTF-8 @@ -2059,7 +2059,7 @@ void CMovieBrowser::onDeleteFile(MI_MOVIE_INFO& movieSelectionHandler) msg += "\r\n "; msg += g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2); - if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, msg, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) + if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, msg, CMessageBox::mbrYes, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) { delFile(movieSelectionHandler.file); From d2b942966991afc5f201ba81019067c363b94d9d Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 14 Sep 2012 16:41:31 +0200 Subject: [PATCH 16/64] *CTextBox: add methodes setTextMode() and setBackGroundColor() --- src/gui/widget/textbox.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index c57a27419..dfdd3f45c 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -130,7 +130,18 @@ class CTextBox CFrameBuffer * frameBuffer; int max_width; int text_border_width; + public: + /* Variables */ + typedef enum mode_ + { + AUTO_WIDTH = 0x01, + AUTO_HIGH = 0x02, + SCROLL = 0x04, + CENTER = 0x40, + NO_AUTO_LINEBREAK = 0x80 + } mode; + /* Constructor */ CTextBox(); CTextBox( const char * text); @@ -152,6 +163,8 @@ class CTextBox void setBackGroundRadius(const int radius, const int type){m_nBgRadius = radius; m_nBgRadiusType = type;}; void setTextBorderWidth(int border); void setTextFont(Font* font_text); + void setTextMode(const mode text_mode){m_nMode = text_mode;}; + void setBackGroundColor(CFBWindow::color_t textBackgroundColor){m_textBackgroundColor = textBackgroundColor;}; inline bool isPainted(void) {if( frameBuffer == NULL) return (false); else return (true);}; inline CBox getWindowsPos(void) {return(m_cFrame);}; @@ -162,17 +175,6 @@ class CTextBox void paint (void); void hide (void); - - - /* Variables */ - typedef enum mode_ - { - AUTO_WIDTH = 0x01, - AUTO_HIGH = 0x02, - SCROLL = 0x04, - CENTER = 0x40, - NO_AUTO_LINEBREAK = 0x80 - } mode; }; #endif // !defined(AFX_TEXTBOX_H__208DED01_ABEC_491C_A632_5B21057DC5D8__INCLUDED_) From 342fa5f88a2d59c55992ed9aef0d1cb25ca08d82 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 14 Sep 2012 20:44:56 +0200 Subject: [PATCH 17/64] *CTextBox/CMsgBox: reduce data type conflicts --- src/gui/widget/msgbox.h | 4 ++-- src/gui/widget/textbox.h | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/gui/widget/msgbox.h b/src/gui/widget/msgbox.h index ead68cda1..a30186389 100644 --- a/src/gui/widget/msgbox.h +++ b/src/gui/widget/msgbox.h @@ -75,7 +75,7 @@ class CMsgBox mbAll = 0x07, mbBack = 0x08 }; - enum mode_ + enum modes { AUTO_WIDTH = 0x01, AUTO_HIGH = 0x02, @@ -85,7 +85,7 @@ class CMsgBox BORDER = 0x20, CENTER = 0x40, NO_AUTO_LINEBREAK= 0x80 - }mode; + }; private: /* Functions */ diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index dfdd3f45c..d719c5291 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -83,8 +83,19 @@ class CBox int iHeight; }; -class CTextBox +class CTextBox { + public: + /* Variables */ + enum textbox_modes + { + AUTO_WIDTH = 0x01, + AUTO_HIGH = 0x02, + SCROLL = 0x04, + CENTER = 0x40, + NO_AUTO_LINEBREAK = 0x80 + }; + private: /* Functions */ void refreshTextLineArray(void); @@ -132,22 +143,12 @@ class CTextBox int text_border_width; public: - /* Variables */ - typedef enum mode_ - { - AUTO_WIDTH = 0x01, - AUTO_HIGH = 0x02, - SCROLL = 0x04, - CENTER = 0x40, - NO_AUTO_LINEBREAK = 0x80 - } mode; - /* Constructor */ CTextBox(); CTextBox( const char * text); CTextBox( const char * text, Font* font_text, - const int mode, + const int pmode, const CBox* position, CFBWindow::color_t textBackgroundColor = COL_MENUCONTENT_PLUS_0); @@ -163,7 +164,7 @@ class CTextBox void setBackGroundRadius(const int radius, const int type){m_nBgRadius = radius; m_nBgRadiusType = type;}; void setTextBorderWidth(int border); void setTextFont(Font* font_text); - void setTextMode(const mode text_mode){m_nMode = text_mode;}; + void setTextMode(const int text_mode){m_nMode = text_mode;}; void setBackGroundColor(CFBWindow::color_t textBackgroundColor){m_textBackgroundColor = textBackgroundColor;}; inline bool isPainted(void) {if( frameBuffer == NULL) return (false); else return (true);}; From 323393548df1c6ff6ca182dbf786aabf7eb41395 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 16 Sep 2012 22:10:31 +0200 Subject: [PATCH 18/64] *CTextBox: some small style clean ups for better readability --- src/gui/widget/textbox.cpp | 56 ++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 18a39ebb5..0b6dce25d 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -75,25 +75,27 @@ CTextBox::CTextBox(const char * text, Font* font_text, const int pmode, //TRACE("[CTextBox] new\r\n"); initVar(); - frameBuffer = NULL; - max_width = 0; + frameBuffer = NULL; + max_width = 0; - if(text != NULL) m_cText = text; - if(font_text != NULL) m_pcFontText = font_text; + if(text != NULL) + m_cText = text; + + if(font_text != NULL) + m_pcFontText = font_text; + if(position != NULL) { - m_cFrame = *position; - m_nMaxHeight = m_cFrame.iHeight; - m_nMaxWidth = m_cFrame.iWidth; + m_cFrame = *position; + m_nMaxHeight = m_cFrame.iHeight; + m_nMaxWidth = m_cFrame.iWidth; } - m_nMode = pmode; + m_nMode = pmode; /* in case of auto line break, we do no support auto width yet */ if( !(pmode & NO_AUTO_LINEBREAK)) - { m_nMode = m_nMode & ~AUTO_WIDTH; /* delete any AUTO_WIDTH*/ - } #if 0 TRACE(" Mode: "); @@ -106,8 +108,8 @@ CTextBox::CTextBox(const char * text, Font* font_text, const int pmode, #endif //TRACE(" CTextBox::m_cText: %d, m_nMode %d\t\r\n",m_cText.size(),m_nMode); - m_textBackgroundColor = textBackgroundColor; - m_nFontTextHeight = m_pcFontText->getHeight(); + m_textBackgroundColor = textBackgroundColor; + m_nFontTextHeight = m_pcFontText->getHeight(); //TRACE(" CTextBox::m_nFontTextHeight: %d\t\r\n",m_nFontTextHeight); /* Initialise the window frames first */ @@ -123,7 +125,9 @@ CTextBox::CTextBox(const char * text) initVar(); frameBuffer = NULL; - if(text != NULL) m_cText = *text; + + if(text != NULL) + m_cText = *text; /* Initialise the window frames first */ initFramesRel(); @@ -160,19 +164,19 @@ void CTextBox::initVar(void) m_cText = ""; m_nMode = SCROLL; - m_pcFontText = NULL; - m_pcFontText = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]; - m_nFontTextHeight = m_pcFontText->getHeight(); + m_pcFontText = NULL; + m_pcFontText = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]; + m_nFontTextHeight = m_pcFontText->getHeight(); - m_nNrOfPages = 1; - m_nNrOfLines = 0; - m_nLinesPerPage = 0; - m_nCurrentLine = 0; - m_nCurrentPage = 0; - text_border_width = 8; + m_nNrOfPages = 1; + m_nNrOfLines = 0; + m_nLinesPerPage = 0; + m_nCurrentLine = 0; + m_nCurrentPage = 0; + text_border_width = 8; m_cFrame.iX = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - MIN_WINDOW_WIDTH) >>1); - m_cFrame.iWidth = MIN_WINDOW_WIDTH; + m_cFrame.iWidth = MIN_WINDOW_WIDTH; m_cFrame.iY = g_settings.screen_StartY + ((g_settings.screen_EndY - g_settings.screen_StartY - MIN_WINDOW_HEIGHT) >>1); m_cFrame.iHeight = MIN_WINDOW_HEIGHT; @@ -181,9 +185,9 @@ void CTextBox::initVar(void) m_textBackgroundColor = COL_MENUCONTENT_PLUS_0; m_textColor = COL_MENUCONTENT; - m_nPaintBackground = true; - m_nBgRadius = 0; - m_nBgRadiusType = CORNER_ALL; + m_nPaintBackground = true; + m_nBgRadius = 0; + m_nBgRadiusType = CORNER_ALL; m_cLineArray.clear(); } From 55896356f158f00a425524784470b5fdf814b80a Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 5 Nov 2012 20:57:57 +0100 Subject: [PATCH 19/64] *CTextBox: move framebuffer define only into initVar framebuffer = NULL was called in all constructors, so it should be enough to define this only at one point. --- src/gui/widget/textbox.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 0b6dce25d..657ecf559 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -74,8 +74,7 @@ CTextBox::CTextBox(const char * text, Font* font_text, const int pmode, { //TRACE("[CTextBox] new\r\n"); initVar(); - - frameBuffer = NULL; + max_width = 0; if(text != NULL) @@ -124,8 +123,6 @@ CTextBox::CTextBox(const char * text) //TRACE("[CTextBox] new\r\n"); initVar(); - frameBuffer = NULL; - if(text != NULL) m_cText = *text; @@ -156,6 +153,8 @@ CTextBox::~CTextBox() void CTextBox::initVar(void) { //TRACE("[CTextBox]->InitVar\r\n"); + frameBuffer = NULL; + m_showTextFrame = 0; m_nNrOfNewLine = 0; m_nMaxLineWidth = 0; From d7dc44146c625c366a2f0ff70d901a4f953b8ee6 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 18 Sep 2012 09:41:57 +0100 Subject: [PATCH 20/64] *CTextBox: add missed init of lineBreakWidth lineBreakWidth is not initialized, but some othe values also not defined, here is seems somthing wrong --- src/gui/widget/textbox.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 657ecf559..17998be9b 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -295,7 +295,7 @@ void CTextBox::refreshTextLineArray(void) int pos = 0; int aktWidth = 0; int aktWordWidth = 0; - int lineBreakWidth; + int lineBreakWidth = 0; int maxTextWidth = 0; m_nNrOfNewLine = 0; @@ -307,15 +307,20 @@ void CTextBox::refreshTextLineArray(void) m_cLineArray.clear(); m_nNrOfLines = 0; - if( m_nMode & AUTO_WIDTH) + if( m_nMode & AUTO_WIDTH){ /* In case of autowidth, we calculate the max allowed width of the textbox */ lineBreakWidth = MAX_WINDOW_WIDTH - m_cFrameScrollRel.iWidth - 2*text_border_width; - else + + }else{ /* If not autowidth, we just take the actuall textframe width */ lineBreakWidth = m_cFrameTextRel.iWidth - 2*text_border_width; + } + if(max_width) lineBreakWidth = max_width; - //printf("TextBox: lineBreakWidth %d\n", lineBreakWidth); + + //TRACE("[CTextBox] line %d: lineBreakWidth %d\n", __LINE__, lineBreakWidth); + int TextChars = m_cText.size(); // do not parse, if text is empty if(TextChars > 0) From ad72c6247116df19d0196061efd41ab15ca64dfb Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 19 Sep 2012 08:35:01 +0100 Subject: [PATCH 21/64] *CTextBox: remove frameBuffer = NULL already happens in initVar() --- src/gui/widget/textbox.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 17998be9b..74e7ad061 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -138,8 +138,6 @@ CTextBox::CTextBox() //TRACE("[CTextBox] new\r\n"); initVar(); initFramesRel(); - - frameBuffer = NULL; } CTextBox::~CTextBox() @@ -310,7 +308,6 @@ void CTextBox::refreshTextLineArray(void) if( m_nMode & AUTO_WIDTH){ /* In case of autowidth, we calculate the max allowed width of the textbox */ lineBreakWidth = MAX_WINDOW_WIDTH - m_cFrameScrollRel.iWidth - 2*text_border_width; - }else{ /* If not autowidth, we just take the actuall textframe width */ lineBreakWidth = m_cFrameTextRel.iWidth - 2*text_border_width; From 57cb8cc3e0002a95786029f7106a8c1dab791d50 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 19 Sep 2012 08:48:09 +0100 Subject: [PATCH 22/64] *CTextBox: style, reworked statements for better readability --- src/gui/widget/textbox.cpp | 91 +++++++++++++++++++++++++------------- 1 file changed, 60 insertions(+), 31 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 74e7ad061..4fbb06f2d 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -98,10 +98,10 @@ CTextBox::CTextBox(const char * text, Font* font_text, const int pmode, #if 0 TRACE(" Mode: "); - if(pmode & SCROLL) TRACE("SCROLL "); - if(pmode & NO_AUTO_LINEBREAK) TRACE("NO_AUTO_LINEBREAK "); - if(pmode & AUTO_WIDTH) TRACE("AUTO_WIDTH "); - if(pmode & AUTO_HIGH) TRACE("AUTO_HIGH"); + if(pmode & SCROLL) TRACE("SCROLL "); + if(pmode & NO_AUTO_LINEBREAK) TRACE("NO_AUTO_LINEBREAK "); + if(pmode & AUTO_WIDTH) TRACE("AUTO_WIDTH "); + if(pmode & AUTO_HIGH) TRACE("AUTO_HIGH"); TRACE("\r\n"); #endif @@ -212,8 +212,11 @@ void CTextBox::reSizeMainFrameWidth(int textWidth) int iNewWindowWidth = textWidth + m_cFrameScrollRel.iWidth + 2*text_border_width; - if( iNewWindowWidth > m_nMaxWidth) iNewWindowWidth = m_nMaxWidth; - if( iNewWindowWidth < MIN_WINDOW_WIDTH) iNewWindowWidth = MIN_WINDOW_WIDTH; + if( iNewWindowWidth > m_nMaxWidth) + iNewWindowWidth = m_nMaxWidth; + + if( iNewWindowWidth < MIN_WINDOW_WIDTH) + iNewWindowWidth = MIN_WINDOW_WIDTH; m_cFrame.iWidth = iNewWindowWidth; @@ -227,8 +230,11 @@ void CTextBox::reSizeMainFrameHeight(int textHeight) int iNewWindowHeight = textHeight + 2*text_border_width; - if( iNewWindowHeight > m_nMaxHeight) iNewWindowHeight = m_nMaxHeight; - if( iNewWindowHeight < MIN_WINDOW_HEIGHT) iNewWindowHeight = MIN_WINDOW_HEIGHT; + if( iNewWindowHeight > m_nMaxHeight) + iNewWindowHeight = m_nMaxHeight; + + if( iNewWindowHeight < MIN_WINDOW_HEIGHT) + iNewWindowHeight = MIN_WINDOW_HEIGHT; m_cFrame.iHeight = iNewWindowHeight; @@ -356,12 +362,15 @@ void CTextBox::refreshTextLineArray(void) aktLine = ""; aktWidth = 0; - if(pos_prev >= TextChars) loop = false; + if(pos_prev >= TextChars) + loop = false; } aktLine += aktWord; aktWidth += aktWordWidth; - if (aktWidth > maxTextWidth) maxTextWidth = aktWidth; + + if (aktWidth > maxTextWidth) + maxTextWidth = aktWidth; //TRACE_1(" aktLine : %s\r\n",aktLine.c_str()); //TRACE_1(" aktWidth: %d aktWordWidth:%d\r\n",aktWidth,aktWordWidth); @@ -376,7 +385,9 @@ void CTextBox::refreshTextLineArray(void) aktLine = ""; aktWidth = 0; m_nNrOfNewLine++; - if(pos_prev >= TextChars) loop = false; + + if(pos_prev >= TextChars) + loop = false; } } } @@ -424,8 +435,11 @@ void CTextBox::refreshTextLineArray(void) void CTextBox::refreshScroll(void) { - if( !(m_nMode & SCROLL)) return; - if( frameBuffer == NULL) return; + if(!(m_nMode & SCROLL)) + return; + + if( frameBuffer == NULL) + return; if (m_nNrOfPages > 1) { @@ -448,14 +462,21 @@ void CTextBox::refreshScroll(void) void CTextBox::refreshText(void) { - if( frameBuffer == NULL) return; - //TRACE(" CTextBox::refreshText: %d,%s\r\n",m_nCurrentLine,m_cLineArray[m_nCurrentLine].c_str()); + //TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__); + + if( frameBuffer == NULL) + return; + + //TRACE("[CTextBox] m_nCurrentLine: %d, m_cLineArray[m_nCurrentLine]: %s\r\n",m_nCurrentLine, m_cLineArray[m_nCurrentLine].c_str()); + //Paint Text Background if (m_nPaintBackground) frameBuffer->paintBoxRel(m_cFrameTextRel.iX+m_cFrame.iX, /*m_cFrameTextRel.iY+*/m_cFrame.iY, m_cFrameTextRel.iWidth, m_cFrameTextRel.iHeight, m_textBackgroundColor, m_nBgRadius, m_nBgRadiusType); - if( m_nNrOfLines <= 0) return; + if( m_nNrOfLines <= 0) + return; + int y = m_cFrameTextRel.iY + text_border_width; int i; int x_center = 0; @@ -478,10 +499,12 @@ void CTextBox::refreshText(void) void CTextBox::scrollPageDown(const int pages) { - if( !(m_nMode & SCROLL)) return; - if( m_nNrOfLines <= 0) return; - TRACE("[CTextBox]->ScrollPageDown \r\n"); - + //TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__); + if( !(m_nMode & SCROLL)) + return; + + if( m_nNrOfLines <= 0) + return; if(m_nCurrentPage + pages < m_nNrOfPages) { @@ -497,10 +520,12 @@ void CTextBox::scrollPageDown(const int pages) void CTextBox::scrollPageUp(const int pages) { - if( !(m_nMode & SCROLL)) return; - if( m_nNrOfLines <= 0) return; - TRACE("[CTextBox]->ScrollPageUp \r\n"); - + //TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__); + if( !(m_nMode & SCROLL)) + return; + + if( m_nNrOfLines <= 0) + return; if(m_nCurrentPage - pages > 0) { @@ -516,9 +541,9 @@ void CTextBox::scrollPageUp(const int pages) void CTextBox::refresh(void) { - if( frameBuffer == NULL) return; - //TRACE("[CTextBox]->Refresh\r\n"); -//printf("setText::refresh!\n"); + //TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__); + if( frameBuffer == NULL) + return; //Paint text refreshScroll(); @@ -544,16 +569,20 @@ bool CTextBox::setText(const std::string* newText, int _max_width) void CTextBox::paint (void) { - if(frameBuffer != NULL) return; - //TRACE("[CTextBox]->paint \r\n"); + //TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__); + if(frameBuffer != NULL) + return; + frameBuffer = CFrameBuffer::getInstance(); refresh(); } void CTextBox::hide (void) { - if(frameBuffer == NULL) return; - //TRACE("[CTextBox]->hide \r\n"); + //TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__); + if(frameBuffer == NULL) + return; + frameBuffer->paintBackgroundBoxRel(m_cFrame.iX, m_cFrame.iY, m_cFrame.iWidth, m_cFrame.iHeight); frameBuffer = NULL; } From ed3be21ebd39a6c85a9b48a28783eade855be01c Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 19 Sep 2012 09:56:04 +0100 Subject: [PATCH 23/64] *CTextBox: add member initFramesAndTextArray(), move max_width into initVar this combines initFramesRel() and refreshTextLineArray() --- src/gui/widget/textbox.cpp | 56 +++++++++++++++++++++++--------------- src/gui/widget/textbox.h | 1 + 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 4fbb06f2d..2ef62f9cf 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -74,10 +74,8 @@ CTextBox::CTextBox(const char * text, Font* font_text, const int pmode, { //TRACE("[CTextBox] new\r\n"); initVar(); - - max_width = 0; - if(text != NULL) + if(text != NULL) m_cText = text; if(font_text != NULL) @@ -109,13 +107,11 @@ CTextBox::CTextBox(const char * text, Font* font_text, const int pmode, m_textBackgroundColor = textBackgroundColor; m_nFontTextHeight = m_pcFontText->getHeight(); + + //TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__); //TRACE(" CTextBox::m_nFontTextHeight: %d\t\r\n",m_nFontTextHeight); - - /* Initialise the window frames first */ - initFramesRel(); - - // than refresh text line array - refreshTextLineArray(); + //Initialise the window frames first and than refresh text line array + initFramesAndTextArray(); } CTextBox::CTextBox(const char * text) @@ -125,19 +121,20 @@ CTextBox::CTextBox(const char * text) if(text != NULL) m_cText = *text; + + //TRACE_1("[CTextBox] %s Line %d text: %s\r\n", __FUNCTION__, __LINE__, text); - /* Initialise the window frames first */ - initFramesRel(); - - // than refresh text line array - refreshTextLineArray(); + //Initialise the window frames first and than refresh text line array + initFramesAndTextArray(); } CTextBox::CTextBox() { //TRACE("[CTextBox] new\r\n"); initVar(); - initFramesRel(); + + //Initialise the window frames first and than refresh text line array + initFramesAndTextArray(); } CTextBox::~CTextBox() @@ -187,6 +184,16 @@ void CTextBox::initVar(void) m_nBgRadiusType = CORNER_ALL; m_cLineArray.clear(); + + max_width = 0; +} + +void CTextBox::initFramesAndTextArray() +{ + /* Initialise the window frames first */ + initFramesRel(); + // than refresh text line array + refreshTextLineArray(); } void CTextBox::setTextFont(Font* font_text) @@ -194,16 +201,16 @@ void CTextBox::setTextFont(Font* font_text) if ((m_pcFontText != font_text) && (font_text != NULL)) { m_pcFontText = font_text; m_nFontTextHeight = m_pcFontText->getHeight(); - initFramesRel(); - refreshTextLineArray(); + //Initialise the window frames first and than refresh text line array + initFramesAndTextArray(); } } void CTextBox::setTextBorderWidth(int border) { text_border_width = border; - initFramesRel(); - refreshTextLineArray(); + //Initialise the window frames first and than refresh text line array + initFramesAndTextArray(); } void CTextBox::reSizeMainFrameWidth(int textWidth) @@ -221,7 +228,8 @@ void CTextBox::reSizeMainFrameWidth(int textWidth) m_cFrame.iWidth = iNewWindowWidth; /* Re-Init the children frames due to new main window */ - initFramesRel(); + //Initialise the window frames first and than refresh text line array + initFramesAndTextArray(); } void CTextBox::reSizeMainFrameHeight(int textHeight) @@ -239,7 +247,8 @@ void CTextBox::reSizeMainFrameHeight(int textHeight) m_cFrame.iHeight = iNewWindowHeight; /* Re-Init the children frames due to new main window */ - initFramesRel(); + //Initialise the window frames first and than refresh text line array + initFramesAndTextArray(); } void CTextBox::initFramesRel(void) @@ -550,6 +559,7 @@ void CTextBox::refresh(void) refreshText(); } + bool CTextBox::setText(const std::string* newText, int _max_width) { //TRACE("[CTextBox]->SetText \r\n"); @@ -560,7 +570,9 @@ bool CTextBox::setText(const std::string* newText, int _max_width) { m_cText = *newText; //m_cText = *newText + "\n"; //FIXME test - refreshTextLineArray(); + reSizeMainFrameHeight(m_cFrame.iHeight); + //Initialise the window frames first and than refresh text line array + initFramesAndTextArray(); refresh(); result = true; } diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index d719c5291..6cf9a305c 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -101,6 +101,7 @@ class CTextBox void refreshTextLineArray(void); void initVar(void); void initFramesRel(void); + void initFramesAndTextArray(); void refreshScroll(void); void refreshText(void); void reSizeMainFrameWidth(int maxTextWidth); From a7bdf41dfec7ff9ace09f76451be316288b1a0d3 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 19 Sep 2012 11:01:28 +0200 Subject: [PATCH 24/64] *CTextBox: trivial change for better readability in initVar() --- src/gui/widget/textbox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 2ef62f9cf..9c4c9c108 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -174,8 +174,8 @@ void CTextBox::initVar(void) m_cFrame.iY = g_settings.screen_StartY + ((g_settings.screen_EndY - g_settings.screen_StartY - MIN_WINDOW_HEIGHT) >>1); m_cFrame.iHeight = MIN_WINDOW_HEIGHT; - m_nMaxHeight = MAX_WINDOW_HEIGHT; - m_nMaxWidth = MAX_WINDOW_WIDTH; + m_nMaxHeight = MAX_WINDOW_HEIGHT; + m_nMaxWidth = MAX_WINDOW_WIDTH; m_textBackgroundColor = COL_MENUCONTENT_PLUS_0; m_textColor = COL_MENUCONTENT; From 550300078e453574a20f24fc596521fdce1e00da Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 19 Sep 2012 11:32:09 +0200 Subject: [PATCH 25/64] *CTextbox: add Member setWindowPos() --- src/gui/widget/textbox.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index 6cf9a305c..ab8f919f7 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -167,6 +167,7 @@ class CTextBox void setTextFont(Font* font_text); void setTextMode(const int text_mode){m_nMode = text_mode;}; void setBackGroundColor(CFBWindow::color_t textBackgroundColor){m_textBackgroundColor = textBackgroundColor;}; + void setWindowPos(const CBox* position){m_cFrame = *position;}; inline bool isPainted(void) {if( frameBuffer == NULL) return (false); else return (true);}; inline CBox getWindowsPos(void) {return(m_cFrame);}; From 1244af46662d0f02e5fba5b938561bfd3853b3f2 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 20 Sep 2012 09:37:15 +0200 Subject: [PATCH 26/64] *CTextBox: fix freezes in channellist and bedit refreshTextLineArray() was to much in reSizeMainFrameHeight() and initFramesRel(), caused endless loops under certain circumstances --- src/gui/widget/textbox.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 9c4c9c108..e3a89aa01 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -228,8 +228,7 @@ void CTextBox::reSizeMainFrameWidth(int textWidth) m_cFrame.iWidth = iNewWindowWidth; /* Re-Init the children frames due to new main window */ - //Initialise the window frames first and than refresh text line array - initFramesAndTextArray(); + initFramesRel(); } void CTextBox::reSizeMainFrameHeight(int textHeight) @@ -247,8 +246,7 @@ void CTextBox::reSizeMainFrameHeight(int textHeight) m_cFrame.iHeight = iNewWindowHeight; /* Re-Init the children frames due to new main window */ - //Initialise the window frames first and than refresh text line array - initFramesAndTextArray(); + initFramesRel(); } void CTextBox::initFramesRel(void) @@ -571,8 +569,8 @@ bool CTextBox::setText(const std::string* newText, int _max_width) m_cText = *newText; //m_cText = *newText + "\n"; //FIXME test reSizeMainFrameHeight(m_cFrame.iHeight); - //Initialise the window frames first and than refresh text line array - initFramesAndTextArray(); + //refresh text line array + refreshTextLineArray(); refresh(); result = true; } From 130d7bf6c2c97821b493437ed9fd4e2aa83eb2b7 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 22 Sep 2012 13:34:33 +0200 Subject: [PATCH 27/64] CTextbox: add members setWindowMaxDimensions, setWindowMinDimensions so we can control max an mnin width and height --- src/gui/widget/textbox.cpp | 56 ++++++++++++++++++++++++++------------ src/gui/widget/textbox.h | 11 ++++++-- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index e3a89aa01..c1e516baf 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -60,8 +60,8 @@ #include "textbox.h" #include -#define SCROLL_FRAME_WIDTH 10 -#define SCROLL_MARKER_BORDER 2 +#define SCROLL_FRAME_WIDTH 10 +#define SCROLL_MARKER_BORDER 2 #define MAX_WINDOW_WIDTH (g_settings.screen_EndX - g_settings.screen_StartX - 40) #define MAX_WINDOW_HEIGHT (g_settings.screen_EndY - g_settings.screen_StartY - 40) @@ -69,6 +69,7 @@ #define MIN_WINDOW_WIDTH ((g_settings.screen_EndX - g_settings.screen_StartX)>>1) #define MIN_WINDOW_HEIGHT 40 + CTextBox::CTextBox(const char * text, Font* font_text, const int pmode, const CBox* position, CFBWindow::color_t textBackgroundColor) { @@ -161,6 +162,7 @@ void CTextBox::initVar(void) m_pcFontText = NULL; m_pcFontText = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]; m_nFontTextHeight = m_pcFontText->getHeight(); + m_nMaxTextWidth = 0; m_nNrOfPages = 1; m_nNrOfLines = 0; @@ -176,6 +178,8 @@ void CTextBox::initVar(void) m_nMaxHeight = MAX_WINDOW_HEIGHT; m_nMaxWidth = MAX_WINDOW_WIDTH; + m_nMinHeight = MIN_WINDOW_HEIGHT; + m_nMinWidth = MIN_WINDOW_WIDTH; m_textBackgroundColor = COL_MENUCONTENT_PLUS_0; m_textColor = COL_MENUCONTENT; @@ -185,7 +189,7 @@ void CTextBox::initVar(void) m_cLineArray.clear(); - max_width = 0; +// max_width = 0; } void CTextBox::initFramesAndTextArray() @@ -213,20 +217,35 @@ void CTextBox::setTextBorderWidth(int border) initFramesAndTextArray(); } +void CTextBox::setWindowMaxDimensions(const int width, const int height) +{ + m_nMaxHeight = height; + m_nMaxWidth = width; +} + +void CTextBox::setWindowMinDimensions(const int width, const int height) +{ + m_nMinHeight = height; + m_nMinWidth = width; +} + void CTextBox::reSizeMainFrameWidth(int textWidth) { - //TRACE("[CTextBox]->ReSizeMainFrameWidth: %d, current: %d\r\n",textWidth,m_cFrameTextRel.iWidth); + TRACE("[CTextBox]->%s: \ntext width: %d\n m_cFrame.iWidth: %d\n m_cFrameTextRel.iWidth: %d\n max_width: %d\n m_nMinWidth: %d\n",__FUNCTION__, textWidth, m_cFrame.iWidth, m_cFrameTextRel.iWidth, m_nMaxWidth, m_nMinWidth); int iNewWindowWidth = textWidth + m_cFrameScrollRel.iWidth + 2*text_border_width; if( iNewWindowWidth > m_nMaxWidth) - iNewWindowWidth = m_nMaxWidth; + iNewWindowWidth = m_nMaxWidth; + + if( iNewWindowWidth < m_nMinWidth) + iNewWindowWidth = m_nMinWidth; - if( iNewWindowWidth < MIN_WINDOW_WIDTH) - iNewWindowWidth = MIN_WINDOW_WIDTH; m_cFrame.iWidth = iNewWindowWidth; + TRACE("[CTextBox]->%s: \ntext width: %d\n m_cFrame.iWidth: %d\n m_cFrameTextRel.iWidth: %d\n max_width: %d\n m_nMinWidth: %d\n",__FUNCTION__, textWidth, m_cFrame.iWidth, m_cFrameTextRel.iWidth, m_nMaxWidth, m_nMinWidth); + /* Re-Init the children frames due to new main window */ initFramesRel(); } @@ -240,8 +259,8 @@ void CTextBox::reSizeMainFrameHeight(int textHeight) if( iNewWindowHeight > m_nMaxHeight) iNewWindowHeight = m_nMaxHeight; - if( iNewWindowHeight < MIN_WINDOW_HEIGHT) - iNewWindowHeight = MIN_WINDOW_HEIGHT; + if( iNewWindowHeight < m_nMinHeight) + iNewWindowHeight = m_nMinHeight; m_cFrame.iHeight = iNewWindowHeight; @@ -307,7 +326,6 @@ void CTextBox::refreshTextLineArray(void) int aktWidth = 0; int aktWordWidth = 0; int lineBreakWidth = 0; - int maxTextWidth = 0; m_nNrOfNewLine = 0; @@ -320,14 +338,14 @@ void CTextBox::refreshTextLineArray(void) if( m_nMode & AUTO_WIDTH){ /* In case of autowidth, we calculate the max allowed width of the textbox */ - lineBreakWidth = MAX_WINDOW_WIDTH - m_cFrameScrollRel.iWidth - 2*text_border_width; + lineBreakWidth = m_nMaxWidth - m_cFrameScrollRel.iWidth - 2*text_border_width; }else{ /* If not autowidth, we just take the actuall textframe width */ lineBreakWidth = m_cFrameTextRel.iWidth - 2*text_border_width; } - if(max_width) - lineBreakWidth = max_width; + if(m_nMaxWidth) + lineBreakWidth = m_nMaxWidth; //TRACE("[CTextBox] line %d: lineBreakWidth %d\n", __LINE__, lineBreakWidth); @@ -376,8 +394,8 @@ void CTextBox::refreshTextLineArray(void) aktLine += aktWord; aktWidth += aktWordWidth; - if (aktWidth > maxTextWidth) - maxTextWidth = aktWidth; + if (aktWidth > m_nMaxTextWidth) + m_nMaxTextWidth = aktWidth; //TRACE_1(" aktLine : %s\r\n",aktLine.c_str()); //TRACE_1(" aktWidth: %d aktWordWidth:%d\r\n",aktWidth,aktWordWidth); @@ -403,7 +421,7 @@ void CTextBox::refreshTextLineArray(void) /* check if we have to recalculate the window frame size, due to auto width and auto height */ if( m_nMode & AUTO_WIDTH) { - reSizeMainFrameWidth(maxTextWidth); + reSizeMainFrameWidth(m_nMaxTextWidth); } if(m_nMode & AUTO_HIGH) @@ -558,11 +576,13 @@ void CTextBox::refresh(void) } -bool CTextBox::setText(const std::string* newText, int _max_width) +bool CTextBox::setText(const std::string* newText, int max_width) { //TRACE("[CTextBox]->SetText \r\n"); bool result = false; - max_width = _max_width; + if (max_width>0) + m_nMaxTextWidth = max_width; + //printf("setText: _max_width %d max_width %d\n", _max_width, max_width); if (newText != NULL) { diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index ab8f919f7..4b1f87238 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -119,6 +119,10 @@ class CTextBox int m_nMaxHeight; int m_nMaxWidth; + int m_nMinHeight; + int m_nMinWidth; + + int m_nMaxTextWidth; int m_nMode; @@ -140,7 +144,8 @@ class CTextBox fb_pixel_t m_textColor; CFrameBuffer * frameBuffer; - int max_width; +/* int max_width;*/ + int text_border_width; public: @@ -160,7 +165,7 @@ class CTextBox void scrollPageDown(const int pages); void scrollPageUp(const int pages); void enableBackgroundPaint(bool mode = true){m_nPaintBackground = mode;}; - bool setText(const std::string* newText, int _max_width = 0); + bool setText(const std::string* newText, int max_width = 0); void setTextColor(fb_pixel_t color_text){ m_textColor = color_text;}; void setBackGroundRadius(const int radius, const int type){m_nBgRadius = radius; m_nBgRadiusType = type;}; void setTextBorderWidth(int border); @@ -168,6 +173,8 @@ class CTextBox void setTextMode(const int text_mode){m_nMode = text_mode;}; void setBackGroundColor(CFBWindow::color_t textBackgroundColor){m_textBackgroundColor = textBackgroundColor;}; void setWindowPos(const CBox* position){m_cFrame = *position;}; + void setWindowMaxDimensions(const int width, const int height); + void setWindowMinDimensions(const int width, const int height); inline bool isPainted(void) {if( frameBuffer == NULL) return (false); else return (true);}; inline CBox getWindowsPos(void) {return(m_cFrame);}; From 07fa858d6cca6ff1a8de72ea67d1cc6222d577f4 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 22 Sep 2012 21:33:40 +0200 Subject: [PATCH 28/64] *CTextBox: add missing textmode comments --- src/gui/widget/textbox.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index 4b1f87238..de5f60416 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -89,11 +89,11 @@ class CTextBox /* Variables */ enum textbox_modes { - AUTO_WIDTH = 0x01, - AUTO_HIGH = 0x02, - SCROLL = 0x04, - CENTER = 0x40, - NO_AUTO_LINEBREAK = 0x80 + AUTO_WIDTH = 0x01, //auto adapt frame width to max width or max text width, text is painted with auto linebreak + AUTO_HIGH = 0x02, //auto adapt frame height to max height, text is painted with auto linebreak + SCROLL = 0x04, //frame box contains scrollbars on long text + CENTER = 0x40, //paint text centered + NO_AUTO_LINEBREAK = 0x80 //paint text without auto linebreak, cutting text }; private: From c9472dc3f3cf62b01016eefaccca8081559b263d Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 22 Sep 2012 21:50:27 +0200 Subject: [PATCH 29/64] *CTextBox: set text y position depends of lines count If we have only one line, text will be painted horizontal centered, otherwise text begins on top of frame. --- src/gui/widget/textbox.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index c1e516baf..76112732f 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -506,8 +506,14 @@ void CTextBox::refreshText(void) int i; int x_center = 0; -// y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * std::min(m_nLinesPerPage, m_nNrOfLines)) >> 1) - text_border_width; - y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * m_nLinesPerPage) >> 1) - text_border_width; + // set text y position depends of lines count + if (m_nNrOfLines > 1) + // move to top of frame + y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * m_nLinesPerPage) >> 1) - text_border_width; + else + // fit into mid of frame space + y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * std::min(m_nLinesPerPage, m_nNrOfLines)) >> 1) - text_border_width; + for(i = m_nCurrentLine; i < m_nNrOfLines && i < m_nCurrentLine + m_nLinesPerPage; i++) { From c25edc0b74fbfc9f368c22a3daee633f07905c8f Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 22 Sep 2012 22:29:49 +0200 Subject: [PATCH 30/64] *CTextbox: add text align option RIGHT This supports paint of text on the right side of frame and also considers scroll bar width. --- src/gui/widget/textbox.cpp | 9 ++++++++- src/gui/widget/textbox.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 76112732f..33b226f24 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -501,6 +501,7 @@ void CTextBox::refreshText(void) if( m_nNrOfLines <= 0) return; + int y = m_cFrameTextRel.iY + text_border_width; int i; @@ -518,8 +519,14 @@ void CTextBox::refreshText(void) { //calculate centered xpos - if( m_nMode & CENTER ) + if( m_nMode & CENTER ){ x_center = (m_cFrameTextRel.iWidth - m_pcFontText->getRenderWidth(m_cLineArray[i], true))>>1; + } + else if ( m_nMode & RIGHT ){ + x_center = (m_cFrameTextRel.iWidth - m_pcFontText->getRenderWidth(m_cLineArray[i], true)); + if ( m_nMode & SCROLL ) + x_center -= SCROLL_FRAME_WIDTH; + } m_pcFontText->RenderString(m_cFrameTextRel.iX + text_border_width + x_center+m_cFrame.iX, y+m_cFrame.iY, m_cFrameTextRel.iWidth, m_cLineArray[i].c_str(), diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index de5f60416..d12c05c67 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -93,6 +93,7 @@ class CTextBox AUTO_HIGH = 0x02, //auto adapt frame height to max height, text is painted with auto linebreak SCROLL = 0x04, //frame box contains scrollbars on long text CENTER = 0x40, //paint text centered + RIGHT = 0x100, //paint text right NO_AUTO_LINEBREAK = 0x80 //paint text without auto linebreak, cutting text }; From 33e684bc204bf2b4edbc04a1748faa693cf28ded Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 22 Sep 2012 23:17:30 +0200 Subject: [PATCH 31/64] *CTextBox: add optional text align TOP --- src/gui/widget/textbox.cpp | 4 ++-- src/gui/widget/textbox.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 33b226f24..a4b182011 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -507,8 +507,8 @@ void CTextBox::refreshText(void) int i; int x_center = 0; - // set text y position depends of lines count - if (m_nNrOfLines > 1) + // set text y position + if (m_nMode & TOP) // move to top of frame y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * m_nLinesPerPage) >> 1) - text_border_width; else diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index d12c05c67..58d77df5d 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -94,6 +94,7 @@ class CTextBox SCROLL = 0x04, //frame box contains scrollbars on long text CENTER = 0x40, //paint text centered RIGHT = 0x100, //paint text right + TOP = 0x200, //paint text on top of frame NO_AUTO_LINEBREAK = 0x80 //paint text without auto linebreak, cutting text }; From fee315f642e69b0fa799aab80c9103aca42e5ad9 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 24 Sep 2012 16:35:38 +0200 Subject: [PATCH 32/64] *CTextBox: add option BOTTOM BOTTOM was missed --- src/gui/widget/textbox.cpp | 6 +++++- src/gui/widget/textbox.h | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index a4b182011..fc8039284 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -492,7 +492,7 @@ void CTextBox::refreshText(void) if( frameBuffer == NULL) return; - //TRACE("[CTextBox] m_nCurrentLine: %d, m_cLineArray[m_nCurrentLine]: %s\r\n",m_nCurrentLine, m_cLineArray[m_nCurrentLine].c_str()); + //TRACE("[CTextBox] m_nCurrentLine: %d, m_nNrOfLines %d, m_cLineArray[m_nCurrentLine]: %s\r\n",m_nCurrentLine, m_nNrOfLines, m_cLineArray[m_nCurrentLine].c_str()); //Paint Text Background if (m_nPaintBackground) @@ -511,6 +511,10 @@ void CTextBox::refreshText(void) if (m_nMode & TOP) // move to top of frame y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * m_nLinesPerPage) >> 1) - text_border_width; + else if (m_nMode & BOTTOM) + // move to bottom of frame + y += m_cFrameTextRel.iHeight - text_border_width - (m_nNrOfLines > 1 ? (m_nNrOfLines-1)*m_nFontTextHeight : 0) ; + //m_nFontTextHeight + text_border_width /*- ((m_cFrameTextRel.iHeight + m_nFontTextHeight*/ * m_nLinesPerPage/*) >> 1)*/; else // fit into mid of frame space y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * std::min(m_nLinesPerPage, m_nNrOfLines)) >> 1) - text_border_width; diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index 58d77df5d..b7e8c1166 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -93,9 +93,10 @@ class CTextBox AUTO_HIGH = 0x02, //auto adapt frame height to max height, text is painted with auto linebreak SCROLL = 0x04, //frame box contains scrollbars on long text CENTER = 0x40, //paint text centered - RIGHT = 0x100, //paint text right - TOP = 0x200, //paint text on top of frame - NO_AUTO_LINEBREAK = 0x80 //paint text without auto linebreak, cutting text + RIGHT = 0x80, //paint text right + TOP = 0x100, //paint text on top of frame + BOTTOM = 0x200, //paint text on bottom of frame + NO_AUTO_LINEBREAK = 0x400 //paint text without auto linebreak, cutting text }; private: From 55bc93f64226714d48c3ef4d1817764767b45d55 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 24 Sep 2012 17:38:43 +0200 Subject: [PATCH 33/64] *CMovieBrowser: apply CTextBox::TOP for movie infobox Default align is centered and to beware the old window style must add CTextBox::TOP --- src/gui/moviebrowser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 2a5a3a2c7..1fd5de186 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -1120,7 +1120,7 @@ int CMovieBrowser::paint(void) m_pcFilter = new CListFrame(&m_FilterLines, font, CListFrame::SCROLL | CListFrame::TITLE, &m_cBoxFrameFilter, g_Locale->getText(LOCALE_MOVIEBROWSER_HEAD_FILTER), g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]); - m_pcInfo = new CTextBox(" ", NULL, CTextBox::SCROLL, &m_cBoxFrameInfo); + m_pcInfo = new CTextBox(" ", NULL, CTextBox::TOP | CTextBox::SCROLL, &m_cBoxFrameInfo); if( m_pcBrowser == NULL || m_pcLastPlay == NULL || From 474a35a254dc1e8fdf415145be6ee0faa5430d01 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 26 Oct 2012 23:50:36 +0200 Subject: [PATCH 34/64] CTextBox: modified AUTO_WIDTH, add some printfs and comments If is set m_nMaxWidth, then use this to calculate m_cFrameTextRel.iWidth. To set m_nMaxWidth use setWindowMaxDimensions(width) and setText(maxwidth). This should help, to paint text with clean linebreaks into defined textboxes. --- src/gui/widget/textbox.cpp | 91 ++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 39 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index fc8039284..801587e20 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -95,15 +95,6 @@ CTextBox::CTextBox(const char * text, Font* font_text, const int pmode, if( !(pmode & NO_AUTO_LINEBREAK)) m_nMode = m_nMode & ~AUTO_WIDTH; /* delete any AUTO_WIDTH*/ -#if 0 - TRACE(" Mode: "); - if(pmode & SCROLL) TRACE("SCROLL "); - if(pmode & NO_AUTO_LINEBREAK) TRACE("NO_AUTO_LINEBREAK "); - if(pmode & AUTO_WIDTH) TRACE("AUTO_WIDTH "); - if(pmode & AUTO_HIGH) TRACE("AUTO_HIGH"); - TRACE("\r\n"); - -#endif //TRACE(" CTextBox::m_cText: %d, m_nMode %d\t\r\n",m_cText.size(),m_nMode); m_textBackgroundColor = textBackgroundColor; @@ -111,6 +102,7 @@ CTextBox::CTextBox(const char * text, Font* font_text, const int pmode, //TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__); //TRACE(" CTextBox::m_nFontTextHeight: %d\t\r\n",m_nFontTextHeight); + //Initialise the window frames first and than refresh text line array initFramesAndTextArray(); } @@ -231,7 +223,7 @@ void CTextBox::setWindowMinDimensions(const int width, const int height) void CTextBox::reSizeMainFrameWidth(int textWidth) { - TRACE("[CTextBox]->%s: \ntext width: %d\n m_cFrame.iWidth: %d\n m_cFrameTextRel.iWidth: %d\n max_width: %d\n m_nMinWidth: %d\n",__FUNCTION__, textWidth, m_cFrame.iWidth, m_cFrameTextRel.iWidth, m_nMaxWidth, m_nMinWidth); + //TRACE("[CTextBox]->%s: \ntext width: %d\n m_cFrame.iWidth: %d\n m_cFrameTextRel.iWidth: %d\n m_nMaxWidth: %d\n m_nMinWidth: %d\n",__FUNCTION__, textWidth, m_cFrame.iWidth, m_cFrameTextRel.iWidth, m_nMaxWidth, m_nMinWidth); int iNewWindowWidth = textWidth + m_cFrameScrollRel.iWidth + 2*text_border_width; @@ -244,8 +236,6 @@ void CTextBox::reSizeMainFrameWidth(int textWidth) m_cFrame.iWidth = iNewWindowWidth; - TRACE("[CTextBox]->%s: \ntext width: %d\n m_cFrame.iWidth: %d\n m_cFrameTextRel.iWidth: %d\n max_width: %d\n m_nMinWidth: %d\n",__FUNCTION__, textWidth, m_cFrame.iWidth, m_cFrameTextRel.iWidth, m_nMaxWidth, m_nMinWidth); - /* Re-Init the children frames due to new main window */ initFramesRel(); } @@ -320,14 +310,14 @@ void CTextBox::initFramesRel(void) void CTextBox::refreshTextLineArray(void) { //TRACE("[CTextBox]->RefreshLineArray \r\n"); - int loop = true; - int pos_prev = 0; - int pos = 0; - int aktWidth = 0; - int aktWordWidth = 0; - int lineBreakWidth = 0; + int loop = true; + int pos_prev = 0; + int pos = 0; + int aktWidth = 0; + int aktWordWidth = 0; + int lineBreakWidth = 0; - m_nNrOfNewLine = 0; + m_nNrOfNewLine = 0; std::string aktLine = ""; std::string aktWord = ""; @@ -341,20 +331,29 @@ void CTextBox::refreshTextLineArray(void) lineBreakWidth = m_nMaxWidth - m_cFrameScrollRel.iWidth - 2*text_border_width; }else{ /* If not autowidth, we just take the actuall textframe width */ - lineBreakWidth = m_cFrameTextRel.iWidth - 2*text_border_width; + lineBreakWidth = std::max(m_nMaxWidth, m_cFrameTextRel.iWidth - 2*text_border_width); } - if(m_nMaxWidth) - lineBreakWidth = m_nMaxWidth; +// if(m_nMaxWidth) +// lineBreakWidth = m_nMaxWidth; //TRACE("[CTextBox] line %d: lineBreakWidth %d\n", __LINE__, lineBreakWidth); int TextChars = m_cText.size(); // do not parse, if text is empty - if(TextChars > 0) + if(TextChars == 0) + { + m_nNrOfPages = 0; + m_nNrOfLines = 0; + m_nCurrentPage = 0; + m_nCurrentLine = 0; + m_nLinesPerPage = 1; + } + else { while(loop) { + //manage auto linebreak, if(m_nMode & NO_AUTO_LINEBREAK) pos = m_cText.find_first_of("\n",pos_prev); else @@ -369,16 +368,20 @@ void CTextBox::refreshTextLineArray(void) //TRACE_1(" Textend found\r\n"); } + //find current word between start pos and next pos (next possible \n) aktWord = m_cText.substr(pos_prev, pos - pos_prev + 1); + + //calculate length of current found word aktWordWidth = m_pcFontText->getRenderWidth(aktWord, true); + + //set next start pos pos_prev = pos + 1; //if(aktWord.find(""") == ) if(1) { //TRACE_1(" aktWord: >%s< pos:%d\r\n",aktWord.c_str(),pos); - if( aktWidth + aktWordWidth > lineBreakWidth && - !(m_nMode & NO_AUTO_LINEBREAK)) + if( (aktWidth + aktWordWidth) > lineBreakWidth && !(m_nMode & NO_AUTO_LINEBREAK)) { /* we need a new line before we can continue */ m_cLineArray.push_back(aktLine); @@ -391,16 +394,19 @@ void CTextBox::refreshTextLineArray(void) loop = false; } + //add current word to current line aktLine += aktWord; + //set current line width aktWidth += aktWordWidth; - + + //set max text width, if required if (aktWidth > m_nMaxTextWidth) m_nMaxTextWidth = aktWidth; + //TRACE_1(" aktLine : %s\r\n",aktLine.c_str()); //TRACE_1(" aktWidth: %d aktWordWidth:%d\r\n",aktWidth,aktWordWidth); - if( ((pos < TextChars) && (m_cText[pos] == '\n')) || - loop == false) + if( ((pos < TextChars) && (m_cText[pos] == '\n')) || loop == false) { // current line ends with an carriage return, make new line if ((pos < TextChars) && (m_cText[pos] == '\n')) @@ -421,7 +427,7 @@ void CTextBox::refreshTextLineArray(void) /* check if we have to recalculate the window frame size, due to auto width and auto height */ if( m_nMode & AUTO_WIDTH) { - reSizeMainFrameWidth(m_nMaxTextWidth); + reSizeMainFrameWidth(m_nMaxTextWidth); } if(m_nMode & AUTO_HIGH) @@ -438,14 +444,7 @@ void CTextBox::refreshTextLineArray(void) m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage; } } - else - { - m_nNrOfPages = 0; - m_nNrOfLines = 0; - m_nCurrentPage = 0; - m_nCurrentLine = 0; - m_nLinesPerPage = 1; - } + #if 0 TRACE_1(" m_nNrOfPages: %d\r\n",m_nNrOfPages); TRACE_1(" m_nNrOfLines: %d\r\n",m_nNrOfLines); @@ -531,8 +530,9 @@ void CTextBox::refreshText(void) if ( m_nMode & SCROLL ) x_center -= SCROLL_FRAME_WIDTH; } - - m_pcFontText->RenderString(m_cFrameTextRel.iX + text_border_width + x_center+m_cFrame.iX, + + //TRACE("[CTextBox] %s Line %d m_cFrame.iX %d m_cFrameTextRel.iX %d\r\n", __FUNCTION__, __LINE__, m_cFrame.iX, m_cFrameTextRel.iX); + m_pcFontText->RenderString(m_cFrame.iX + m_cFrameTextRel.iX + text_border_width + x_center, y+m_cFrame.iY, m_cFrameTextRel.iWidth, m_cLineArray[i].c_str(), m_textColor, 0, true); // UTF-8 y += m_nFontTextHeight; @@ -617,6 +617,19 @@ bool CTextBox::setText(const std::string* newText, int max_width) void CTextBox::paint (void) { //TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__); +#if 0 + TRACE(" Mode: "); + if(m_nMode & SCROLL) TRACE("SCROLL "); + if(m_nMode & NO_AUTO_LINEBREAK) TRACE("NO_AUTO_LINEBREAK "); + if(m_nMode & AUTO_WIDTH) TRACE("AUTO_WIDTH "); + if(m_nMode & AUTO_HIGH) TRACE("AUTO_HIGH "); + if(m_nMode & CENTER) TRACE("CENTER "); + if(m_nMode & RIGHT) TRACE("RIGHT "); + if(m_nMode & TOP) TRACE("TOP "); + if(m_nMode & BOTTOM) TRACE("BOTTOM "); + TRACE("\r\n"); + +#endif if(frameBuffer != NULL) return; From 694d9954159b6aac278f54d89bb6fe31a713f15e Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 5 Nov 2012 21:18:20 +0100 Subject: [PATCH 35/64] CMsgBox: fix build merge error: mode is not declared --- src/gui/widget/msgbox.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/widget/msgbox.cpp b/src/gui/widget/msgbox.cpp index f1e5c06fe..6d797df8d 100644 --- a/src/gui/widget/msgbox.cpp +++ b/src/gui/widget/msgbox.cpp @@ -213,7 +213,6 @@ CMsgBox::~CMsgBox() void CMsgBox::initVar(void) { //TRACE("->CMsgBox::InitVar\r\n"); - mode = AUTO_WIDTH; m_nResult = mbrYes; m_cTitle = ""; m_cIcon = ""; From 6016c60b4c7e61e73c0e932c752c4303780c7f6a Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 5 Nov 2012 21:19:39 +0100 Subject: [PATCH 36/64] CTextBox: fix build merge error, max_width is not declared --- src/gui/widget/textbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 801587e20..fe86218be 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -146,7 +146,7 @@ void CTextBox::initVar(void) m_showTextFrame = 0; m_nNrOfNewLine = 0; m_nMaxLineWidth = 0; - max_width = 0; + m_nMaxTextWidth = 0; m_cText = ""; m_nMode = SCROLL; From 94a49e3a51e8e38b201612bcb03bd450a970d92d Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 5 Nov 2012 22:04:42 +0100 Subject: [PATCH 37/64] CTextBox: remove dub var revert of 6016c60b4c7e61e73c0e932c752c4303780c7f6a --- src/gui/widget/textbox.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index fe86218be..fb19beddb 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -146,7 +146,6 @@ void CTextBox::initVar(void) m_showTextFrame = 0; m_nNrOfNewLine = 0; m_nMaxLineWidth = 0; - m_nMaxTextWidth = 0; m_cText = ""; m_nMode = SCROLL; From 24ffee6bb213a87c07cd373383e7edcd355e3682 Mon Sep 17 00:00:00 2001 From: "svenhoefer, snafed" Date: Tue, 6 Nov 2012 22:05:45 +0100 Subject: [PATCH 38/64] - infoviewer_bb.cpp,h: fix determination of hdd-usage in thread --- src/gui/infoviewer_bb.cpp | 29 ++++++++++++++++------------- src/gui/infoviewer_bb.h | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index b6036c647..cf033a766 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -87,6 +87,7 @@ CInfoViewerBB::CInfoViewerBB() pthread_detach(scrambledT); } #endif + hddpercent = 0; hddperT = 0; hddperTflag = false; bbIconInfo[0].x = 0; @@ -612,20 +613,17 @@ void CInfoViewerBB::showSysfsHdd() percent = (u * 100ULL) / t; showBarSys(percent); -#if 0 //HDD info in a seperate thread if(!hddperTflag) { hddperTflag=true; pthread_create(&hddperT, NULL, hddperThread, (void*) this); pthread_detach(hddperT); } -#else - if (!check_dir(g_settings.network_nfs_recordingdir)) { - if (get_fs_usage(g_settings.network_nfs_recordingdir, t, u)) - percent = (u * 100ULL) / t; - showBarHdd(percent); - } -#endif + + if (check_dir(g_settings.network_nfs_recordingdir) == 0) + showBarHdd(hddpercent); + else + showBarHdd(-1); } } @@ -633,11 +631,10 @@ void* CInfoViewerBB::hddperThread(void *arg) { CInfoViewerBB *infoViewerBB = (CInfoViewerBB*) arg; - int percent = 0; + infoViewerBB->hddpercent = 0; long t, u; if (get_fs_usage(g_settings.network_nfs_recordingdir, t, u)) - percent = (u * 100ULL) / t; - infoViewerBB->showBarHdd(percent); + infoViewerBB->hddpercent = (u * 100ULL) / t; infoViewerBB->hddperTflag=false; pthread_exit(NULL); @@ -651,8 +648,14 @@ void CInfoViewerBB::showBarSys(int percent) void CInfoViewerBB::showBarHdd(int percent) { - if (is_visible) - hddscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, percent, 100); + if (is_visible) { + if (percent >= 0) + hddscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, percent, 100); + else { + frameBuffer->paintBoxRel(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, COL_INFOBAR_BUTTONS_BACKGROUND); + hddscale->reset(); + } + } } void CInfoViewerBB::paint_ca_icons(int caid, char * icon, int &icon_space_offset) diff --git a/src/gui/infoviewer_bb.h b/src/gui/infoviewer_bb.h index 41bb17cb0..d5f4230c5 100644 --- a/src/gui/infoviewer_bb.h +++ b/src/gui/infoviewer_bb.h @@ -124,6 +124,7 @@ class CInfoViewerBB void showBarSys(int percent = 0); void showBarHdd(int percent = 0); + int hddpercent; pthread_t hddperT; static void* hddperThread(void *arg); bool hddperTflag; From e145f9a5e84f3958be6033daa43afdb5d37b8a75 Mon Sep 17 00:00:00 2001 From: snafed Date: Tue, 6 Nov 2012 23:04:55 +0100 Subject: [PATCH 39/64] - add pictureviewer to info-key in audioplayer --- src/gui/audioplayer.cpp | 83 ++++++++++++++++++++++++++++----------- src/gui/audioplayer.h | 4 ++ src/gui/pictureviewer.cpp | 33 ++++++++++------ src/gui/pictureviewer.h | 5 +++ 4 files changed, 92 insertions(+), 33 deletions(-) diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index ffc80f4ae..c7e82d9ba 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -65,6 +65,8 @@ #include #include +#include "gui/pictureviewer.h" + #include #include #include @@ -198,6 +200,8 @@ void CAudioPlayerGui::Init(void) m_selected = 0; m_metainfo.clear(); + pictureviewer = false; + m_select_title_by_name = g_settings.audioplayer_select_title_by_name==1; if (strlen(g_settings.network_nfs_audioplayerdir)!=0) @@ -753,6 +757,22 @@ int CAudioPlayerGui::show() } } } + else if ( (msg == CRCInput::RC_info) && (!m_playlist.empty()) ) + { + pictureviewer = true; + m_frameBuffer->Clear(); + videoDecoder->StopPicture(); + CPictureViewerGui * picture = new CPictureViewerGui(); + picture->m_audioPlayer = this; + picture->exec(this, "audio"); + delete picture; + pictureviewer = false; + videoDecoder->setBlank(true); + videoDecoder->ShowPicture(DATADIR "/neutrino/icons/mp3.jpg"); + CVFD::getInstance()->setMode(CVFD::MODE_AUDIO); + paintLCD(); + screensaver(false); + } else if (msg == CRCInput::RC_help) { if (m_key_level == 2) @@ -904,6 +924,17 @@ bool CAudioPlayerGui::playNext(bool allow_rotate) return(result); } +void CAudioPlayerGui::wantNextPlay() +{ + if ((m_state != CAudioPlayerGui::STOP) && + (CAudioPlayer::getInstance()->getState() == CBaseDec::STOP) && + (!m_playlist.empty())) + { + if (m_curr_audiofile.FileType != CFile::STREAM_AUDIO) + playNext(); + } +} + bool CAudioPlayerGui::playPrev(bool allow_rotate) { bool result = false; @@ -1698,10 +1729,11 @@ const struct button_label AudioPlayerButtons[][4] = void CAudioPlayerGui::paintFoot() { // printf("paintFoot{\n"); -const struct button_label ScondLineButtons[2] = +const struct button_label ScondLineButtons[3] = { { NEUTRINO_ICON_BUTTON_OKAY , LOCALE_AUDIOPLAYER_PLAY }, { NEUTRINO_ICON_BUTTON_HELP , LOCALE_AUDIOPLAYER_KEYLEVEL }, + { NEUTRINO_ICON_BUTTON_INFO , LOCALE_PICTUREVIEWER_HEAD}, }; int top; @@ -1717,8 +1749,7 @@ const struct button_label ScondLineButtons[2] = m_frameBuffer->paintHLine(m_x, m_x + m_width, top, COL_INFOBAR_SHADOW_PLUS_1); if (!m_playlist.empty()) - ::paintButtons(m_x, top+m_buttonHeight, m_width, 2, ScondLineButtons, m_buttonHeight, ButtonWidth); - + ::paintButtons(m_x, top+m_buttonHeight, m_width, 3, ScondLineButtons, m_buttonHeight, ButtonWidth); if (m_key_level == 0) { @@ -1943,12 +1974,16 @@ void CAudioPlayerGui::stop() { m_state = CAudioPlayerGui::STOP; m_current = 0; - //LCD - paintLCD(); - //Display - paintInfo(); - m_key_level = 0; - paintFoot(); + + if (!pictureviewer) + { + //LCD + paintLCD(); + //Display + paintInfo(); + m_key_level = 0; + paintFoot(); + } if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP) CAudioPlayer::getInstance()->stop(); @@ -2022,31 +2057,31 @@ void CAudioPlayerGui::play(unsigned int pos) if (m_selected - m_liststart >= m_listmaxshow && g_settings.audioplayer_follow) { m_liststart = m_selected; - if (!m_screensaver) + if (!m_screensaver && !pictureviewer) paint(); } else if (m_liststart < m_selected && g_settings.audioplayer_follow) { m_liststart = m_selected - m_listmaxshow + 1; - if (!m_screensaver) + if (!m_screensaver && !pictureviewer) paint(); } else { if (old_current >= m_liststart && old_current - m_liststart < m_listmaxshow) { - if (!m_screensaver) + if (!m_screensaver && !pictureviewer) paintItem(old_current - m_liststart); } if (pos >= m_liststart && pos - m_liststart < m_listmaxshow) { - if (!m_screensaver) + if (!m_screensaver && !pictureviewer) paintItem(pos - m_liststart); } if (g_settings.audioplayer_follow) { if (old_selected >= m_liststart && old_selected - m_liststart < m_listmaxshow) - if (!m_screensaver) + if (!m_screensaver && !pictureviewer) paintItem(old_selected - m_liststart); } } @@ -2065,14 +2100,18 @@ void CAudioPlayerGui::play(unsigned int pos) m_curr_audiofile = m_playlist[m_current]; // Play CAudioPlayer::getInstance()->play(&m_curr_audiofile, g_settings.audioplayer_highprio == 1); - //LCD - paintLCD(); - // Display - if (!m_screensaver) - paintInfo(); - m_key_level = 1; - if (!m_screensaver) - paintFoot(); + + if (!pictureviewer) + { + //LCD + paintLCD(); + // Display + if (!m_screensaver) + paintInfo(); + m_key_level = 1; + if (!m_screensaver) + paintFoot(); + } } //------------------------------------------------------------------------ diff --git a/src/gui/audioplayer.h b/src/gui/audioplayer.h index 92ff2a2bb..6a73378e3 100644 --- a/src/gui/audioplayer.h +++ b/src/gui/audioplayer.h @@ -251,11 +251,15 @@ class CAudioPlayerGui : public CMenuTarget bool playNext(bool allow_rotate = false); bool playPrev(bool allow_rotate = false); + bool pictureviewer; + public: CAudioPlayerGui(bool inetmode = false); ~CAudioPlayerGui(); int show(); int exec(CMenuTarget* parent, const std::string & actionKey); + + void wantNextPlay(); }; diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index 4d2d1586c..3165df49b 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -112,8 +112,12 @@ CPictureViewerGui::~CPictureViewerGui() } //------------------------------------------------------------------------ -int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & /*actionKey*/) +int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & actionKey) { + audioplayer = false; + if (actionKey == "audio") + audioplayer = true; + selected = 0; width = w_max (710, 0); height = h_max (570, 0); @@ -159,14 +163,16 @@ int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & /*actionKey // remember last mode m_LastMode=(CNeutrinoApp::getInstance()->getLastMode() | NeutrinoMessages::norezap); - //g_Zapit->setStandby(true); - g_Zapit->lockPlayBack(); + if (!audioplayer) { // !!! why? !!! + //g_Zapit->setStandby(true); + g_Zapit->lockPlayBack(); - // blank background screen - videoDecoder->setBlank(true); + // blank background screen + videoDecoder->setBlank(true); - // Stop Sectionsd - g_Sectionsd->setPauseScanning(true); + // Stop Sectionsd + g_Sectionsd->setPauseScanning(true); + } // Save and Clear background bool usedBackground = frameBuffer->getuseBackground(); @@ -180,11 +186,13 @@ int CPictureViewerGui::exec(CMenuTarget* parent, const std::string & /*actionKey // free picviewer mem m_viewer->Cleanup(); - //g_Zapit->setStandby(false); - g_Zapit->unlockPlayBack(); + if (!audioplayer) { // !!! why? !!! + //g_Zapit->setStandby(false); + g_Zapit->unlockPlayBack(); - // Start Sectionsd - g_Sectionsd->setPauseScanning(false); + // Start Sectionsd + g_Sectionsd->setPauseScanning(false); + } // Restore previous background if (usedBackground) { @@ -226,6 +234,9 @@ int CPictureViewerGui::show() paint(); } + if (audioplayer) + m_audioPlayer->wantNextPlay(); + if (m_state!=SLIDESHOW) timeout=50; // egal else diff --git a/src/gui/pictureviewer.h b/src/gui/pictureviewer.h index 2a72c7728..0909d6ef4 100644 --- a/src/gui/pictureviewer.h +++ b/src/gui/pictureviewer.h @@ -37,6 +37,7 @@ #include #include #include +#include #include @@ -109,10 +110,14 @@ class CPictureViewerGui : public CMenuTarget void showHelp(); void deletePicFile(unsigned int index, bool mode); + bool audioplayer; + public: CPictureViewerGui(); ~CPictureViewerGui(); int exec(CMenuTarget* parent, const std::string & actionKey); + + CAudioPlayerGui *m_audioPlayer; }; From 0c84840e10a86e0cbf2a0369315e638538a03282 Mon Sep 17 00:00:00 2001 From: micha-bbg Date: Mon, 5 Nov 2012 08:13:50 +0100 Subject: [PATCH 40/64] * Software Update with apply the settings (Part9) - Functions now available for internet & local update. - Rename writemtdExt() to applySettings() --- data/locale/deutsch.locale | 1 + data/locale/english.locale | 1 + src/gui/ext_update.cpp | 30 +++++++++++++++++++----------- src/gui/ext_update.h | 9 +++++++-- src/gui/update.cpp | 24 ++++++++++++++---------- src/system/locals.h | 1 + src/system/locals_intern.h | 1 + 7 files changed, 44 insertions(+), 23 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 5c1083695..f1c36c592 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -436,6 +436,7 @@ filesystem.is.utf8 Dateisystem filesystem.is.utf8.option.iso8859.1 ISO-8859-1 filesystem.is.utf8.option.utf8 UTF-8 flashupdate.actionreadflash lese Flash +flashupdate.apply_settings Sollen die aktuellen Einstellungen in das neue Image übernommen werden? flashupdate.cantopenfile kann Datei nicht öffnen flashupdate.cantopenmtd kann MTD nicht öffnen flashupdate.checkupdate_internet Online nach Updates suchen diff --git a/data/locale/english.locale b/data/locale/english.locale index 5642348c2..dfdada318 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -436,6 +436,7 @@ filesystem.is.utf8 file system filesystem.is.utf8.option.iso8859.1 ISO-8859-1 filesystem.is.utf8.option.utf8 UTF-8 flashupdate.actionreadflash reading +flashupdate.apply_settings Import current settings into new image? flashupdate.cantopenfile can't open file flashupdate.cantopenmtd can't open MTD flashupdate.checkupdate_internet Check for online updates diff --git a/src/gui/ext_update.cpp b/src/gui/ext_update.cpp index 6b6f911a8..c8763de72 100644 --- a/src/gui/ext_update.cpp +++ b/src/gui/ext_update.cpp @@ -121,30 +121,38 @@ bool CExtUpdate::ErrorReset(bool modus, const std::string & msg1, const std::str return false; } -bool CExtUpdate::writemtdExt(const std::string & filename) +bool CExtUpdate::applySettings(const std::string & filename, int mode) { if(!FileHelpers) FileHelpers = new CFileHelpers(); - imgFilename = (std::string)g_settings.update_dir + "/" + FILESYSTEM_ENCODING_TO_UTF8_STRING(filename); + + if (mode == MODE_EXPERT) + imgFilename = (std::string)g_settings.update_dir + "/" + FILESYSTEM_ENCODING_TO_UTF8_STRING(filename); + else + imgFilename = FILESYSTEM_ENCODING_TO_UTF8_STRING(filename); + DBG_TIMER_START() - bool ret = writemtdExt(); + bool ret = applySettings(); DBG_TIMER_STOP("Image editing") if (!ret) { if (mtdRamError != "") DisplayErrorMessage(mtdRamError.c_str()); } else { - if ((mtdNumber < 3) || (mtdNumber > 4)) { - const char *err = "invalid mtdNumber\n"; - printf(err); - DisplayErrorMessage(err); - WRITE_UPDATE_LOG("ERROR: %s", err); - return false; + if (mode == MODE_EXPERT) { + if ((mtdNumber < 3) || (mtdNumber > 4)) { + const char *err = "invalid mtdNumber\n"; + printf(err); + DisplayErrorMessage(err); + WRITE_UPDATE_LOG("ERROR: %s", err); + return false; + } } ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SUCCESSFULLY), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); WRITE_UPDATE_LOG("\n"); WRITE_UPDATE_LOG("##### Settings taken. #####\n"); - CFlashExpert::getInstance()->writemtd(filename, mtdNumber); + if (mode == MODE_EXPERT) + CFlashExpert::getInstance()->writemtd(filename, mtdNumber); } return ret; } @@ -166,7 +174,7 @@ bool CExtUpdate::isMtdramLoad() return ret; } -bool CExtUpdate::writemtdExt() +bool CExtUpdate::applySettings() { if(!hintBox) hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_PROCESSED)); diff --git a/src/gui/ext_update.h b/src/gui/ext_update.h index a588cb890..9f0ee6744 100644 --- a/src/gui/ext_update.h +++ b/src/gui/ext_update.h @@ -55,7 +55,7 @@ class CExtUpdate std::string mountPkt; CFileHelpers* FileHelpers; - bool writemtdExt(void); + bool applySettings(void); bool readBackupList(const std::string & dstPath); bool copyFileList(const std::string & fileList, const std::string & dstPath); bool readConfig(const std::string & Config); @@ -69,11 +69,16 @@ class CExtUpdate void updateLog(const char *buf); public: + enum + { + MODE_EXPERT = 0, + MODE_SOFTUPDATE = 1 + }; CExtUpdate(); ~CExtUpdate(); static CExtUpdate* getInstance(); - bool writemtdExt(const std::string & filename); + bool applySettings(const std::string & filename, int mode); bool ErrorReset(bool modus, const std::string & msg1="", const std::string & msg2=""); }; diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 61c971baa..591dcaba9 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -451,16 +451,20 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &) CNeutrinoApp::getInstance()->exec(NULL, "savesettings"); sleep(2); //flash it... -#ifdef DEBUG1 - if(1) -#else - if(!ft.program(filename, 80, 100)) -#endif - { - hide(); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, ft.getErrorMessage().c_str()); // UTF-8 + + if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes) + if (!CExtUpdate::getInstance()->applySettings(filename, CExtUpdate::MODE_SOFTUPDATE)) return menu_return::RETURN_REPAINT; - } + +#ifdef DEBUG1 + if(1) { +#else + if(!ft.program(filename, 80, 100)) { +#endif + hide(); + ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, ft.getErrorMessage().c_str()); // UTF-8 + return menu_return::RETURN_REPAINT; + } //status anzeigen showGlobalStatus(100); @@ -690,7 +694,7 @@ int CFlashExpert::exec(CMenuTarget* parent, const std::string & actionKey) showFileSelector(""); } else { if(selectedMTD == 10) { - CExtUpdate::getInstance()->writemtdExt(actionKey); + CExtUpdate::getInstance()->applySettings(actionKey, CExtUpdate::MODE_EXPERT); } else if(selectedMTD==-1) { writemtd(actionKey, MTD_OF_WHOLE_IMAGE); diff --git a/src/system/locals.h b/src/system/locals.h index 0a6b67178..e7ade5664 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -463,6 +463,7 @@ typedef enum LOCALE_FILESYSTEM_IS_UTF8_OPTION_ISO8859_1, LOCALE_FILESYSTEM_IS_UTF8_OPTION_UTF8, LOCALE_FLASHUPDATE_ACTIONREADFLASH, + LOCALE_FLASHUPDATE_APPLY_SETTINGS, LOCALE_FLASHUPDATE_CANTOPENFILE, LOCALE_FLASHUPDATE_CANTOPENMTD, LOCALE_FLASHUPDATE_CHECKUPDATE_INTERNET, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index fc38e3589..e9822fb95 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -463,6 +463,7 @@ const char * locale_real_names[] = "filesystem.is.utf8.option.iso8859.1", "filesystem.is.utf8.option.utf8", "flashupdate.actionreadflash", + "flashupdate.apply_settings", "flashupdate.cantopenfile", "flashupdate.cantopenmtd", "flashupdate.checkupdate_internet", From 6472840127bcddc66eb5ff90cc9c9aeb49ec4396 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Wed, 7 Nov 2012 13:02:40 +0100 Subject: [PATCH 41/64] - network_setup.cpp: add more suitable hints to hostname-setup --- data/locale/deutsch.locale | 2 ++ data/locale/english.locale | 2 ++ src/gui/network_setup.cpp | 2 +- src/system/locals.h | 2 ++ src/system/locals_intern.h | 2 ++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 5c1083695..abf12a8b6 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1318,6 +1318,8 @@ networkmenu.dhcp DHCP networkmenu.error_no_address Keine %s-Adresse angegeben! networkmenu.gateway Standard Gateway networkmenu.hostname Hostname +networkmenu.hostname_hint1 Geben sie den Hostnamen ein +networkmenu.hostname_hint2 Eine Änderung benötigt einen Neustart networkmenu.inactive_network Netzwerk nicht aktiviert! networkmenu.ipaddress IP networkmenu.mount Netzwerkfreigaben bearbeiten diff --git a/data/locale/english.locale b/data/locale/english.locale index 5642348c2..85cf50401 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1318,6 +1318,8 @@ networkmenu.dhcp DHCP networkmenu.error_no_address Missing %s-address! networkmenu.gateway default gateway networkmenu.hostname Hostname +networkmenu.hostname_hint1 enter hostname +networkmenu.hostname_hint2 need reboot after change networkmenu.inactive_network Network inactiv! networkmenu.ipaddress IP address networkmenu.mount Edit network shares diff --git a/src/gui/network_setup.cpp b/src/gui/network_setup.cpp index 1e77d421e..db7a36d48 100644 --- a/src/gui/network_setup.cpp +++ b/src/gui/network_setup.cpp @@ -238,7 +238,7 @@ int CNetworkSetup::showNetworkSetup() CIPInput networkSettings_NameServer(LOCALE_NETWORKMENU_NAMESERVER, network_nameserver, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); //hostname - CStringInputSMS networkSettings_Hostname(LOCALE_NETWORKMENU_HOSTNAME, &network_hostname, 30, LOCALE_NETWORKMENU_NTPSERVER_HINT1, LOCALE_NETWORKMENU_NTPSERVER_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-. "); + CStringInputSMS networkSettings_Hostname(LOCALE_NETWORKMENU_HOSTNAME, &network_hostname, 30, LOCALE_NETWORKMENU_HOSTNAME_HINT1, LOCALE_NETWORKMENU_HOSTNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-. "); //auto start CMenuOptionChooser* o1 = new CMenuOptionChooser(LOCALE_NETWORKMENU_SETUPONSTARTUP, &network_automatic_start, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); diff --git a/src/system/locals.h b/src/system/locals.h index 0a6b67178..f1be5b805 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1345,6 +1345,8 @@ typedef enum LOCALE_NETWORKMENU_ERROR_NO_ADDRESS, LOCALE_NETWORKMENU_GATEWAY, LOCALE_NETWORKMENU_HOSTNAME, + LOCALE_NETWORKMENU_HOSTNAME_HINT1, + LOCALE_NETWORKMENU_HOSTNAME_HINT2, LOCALE_NETWORKMENU_INACTIVE_NETWORK, LOCALE_NETWORKMENU_IPADDRESS, LOCALE_NETWORKMENU_MOUNT, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index fc38e3589..a0f282e35 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1345,6 +1345,8 @@ const char * locale_real_names[] = "networkmenu.error_no_address", "networkmenu.gateway", "networkmenu.hostname", + "networkmenu.hostname_hint1", + "networkmenu.hostname_hint2", "networkmenu.inactive_network", "networkmenu.ipaddress", "networkmenu.mount", From c9a6a8721b82ed4a3a83cfddc33a9a3860ae0348 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Wed, 7 Nov 2012 13:49:01 +0100 Subject: [PATCH 42/64] - stringinput.cpp: center NEUTRINO_ICON_NUMERIC_PAD horizontally --- src/gui/widget/stringinput.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index 40ab760db..276cc131c 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -755,7 +755,9 @@ void CStringInputSMS::paint(bool /*unused*/) { CStringInput::paint(true); - frameBuffer->paintIcon(NEUTRINO_ICON_NUMERIC_PAD, x+20+140, y+ hheight+ mheight+ iheight* 3+ 30, 0, COL_MENUCONTENT); + int w = 0, h = 0; + frameBuffer->getIconSize(NEUTRINO_ICON_NUMERIC_PAD, &w, &h); + frameBuffer->paintIcon(NEUTRINO_ICON_NUMERIC_PAD, x + (width/2) - (w/2), y+ hheight+ mheight+ iheight* 3+ 30, 0, COL_MENUCONTENT); //buttonbar ::paintButtons(x, y + height, width, 2, CStringInputSMSButtons); From 7c311a7d97d4765276c74d3077dba42c34bfaf04 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Wed, 7 Nov 2012 20:48:27 +0400 Subject: [PATCH 43/64] zapit/src/capmt.cpp: disable capmt dump --- src/zapit/src/capmt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zapit/src/capmt.cpp b/src/zapit/src/capmt.cpp index b600a2f99..1514cd184 100644 --- a/src/zapit/src/capmt.cpp +++ b/src/zapit/src/capmt.cpp @@ -32,7 +32,7 @@ #include #include -#define DEBUG_CAPMT +//#define DEBUG_CAPMT CCam::CCam() { From 02c3cfb173a269e47b90130c53652c32b8cd3cf1 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Wed, 7 Nov 2012 20:49:06 +0400 Subject: [PATCH 44/64] driver/file.h: define __USE_FILE_OFFSET64 instead of error --- src/driver/file.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/file.h b/src/driver/file.h index 6d62e8e46..5cd11121c 100644 --- a/src/driver/file.h +++ b/src/driver/file.h @@ -37,7 +37,7 @@ in __USE_FILE_OFFSET64 mode */ #ifndef __USE_FILE_OFFSET64 -#error not using 64 bit file offsets +#define __USE_FILE_OFFSET64 #endif /* __USE_FILE__OFFSET64 */ #include From 01383e083d2e7ff8a09b23540dee76c8f5d1a956 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Wed, 7 Nov 2012 20:50:18 +0400 Subject: [PATCH 45/64] gui/start_wizard.cpp: move initial settings question before calling scan setup --- src/gui/start_wizard.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/gui/start_wizard.cpp b/src/gui/start_wizard.cpp index 292bcc9f1..991835987 100644 --- a/src/gui/start_wizard.cpp +++ b/src/gui/start_wizard.cpp @@ -99,12 +99,6 @@ int CStartUpWizard::exec(CMenuTarget* parent, const string & /*actionKey*/) res = CNetworkSetup::getInstance()->exec(NULL, ""); CNetworkSetup::getInstance()->setWizardMode(CNetworkSetup::N_SETUP_MODE_WIZARD_NO); } - if(res != menu_return::RETURN_EXIT_ALL) - { - CScanSetup::getInstance()->setWizardMode(CScanSetup::SCAN_SETUP_MODE_WIZARD); - res = CScanSetup::getInstance()->exec(NULL, ""); - CScanSetup::getInstance()->setWizardMode(CScanSetup::SCAN_SETUP_MODE_WIZARD_NO); - } bool init_settings = false; if (g_info.delivery_system == DVB_S) init_settings = file_exists("/var/tuxbox/config/initial/"); @@ -119,9 +113,13 @@ int CStartUpWizard::exec(CMenuTarget* parent, const string & /*actionKey*/) CZapit::getInstance()->PrepareChannels(); } } + if(res != menu_return::RETURN_EXIT_ALL) + { + CScanSetup::getInstance()->setWizardMode(CScanSetup::SCAN_SETUP_MODE_WIZARD); + res = CScanSetup::getInstance()->exec(NULL, ""); + CScanSetup::getInstance()->setWizardMode(CScanSetup::SCAN_SETUP_MODE_WIZARD_NO); + } } - - killBackgroundLogo(); return res; From 861a5a4a5183f2434f7cf8cf8a25ebb37f1d3f46 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 8 Nov 2012 15:08:08 +0400 Subject: [PATCH 46/64] driver/genpsi.cpp: replace old code with class --- src/driver/{genpsi.c => genpsi.cpp} | 237 ++++++++++++++-------------- src/driver/genpsi.h | 24 ++- 2 files changed, 133 insertions(+), 128 deletions(-) rename src/driver/{genpsi.c => genpsi.cpp} (69%) diff --git a/src/driver/genpsi.c b/src/driver/genpsi.cpp similarity index 69% rename from src/driver/genpsi.c rename to src/driver/genpsi.cpp index 6724369ea..266b727fd 100644 --- a/src/driver/genpsi.c +++ b/src/driver/genpsi.cpp @@ -1,10 +1,6 @@ /* -$Id: genpsi.c,v 1.2 2006/01/16 12:45:54 sat_man Exp $ - Copyright (c) 2004 gmo18t, Germany. All rights reserved. - - aktuelle Versionen gibt es hier: - $Source: /cvs/tuxbox/apps/tuxbox/neutrino/src/driver/genpsi.c,v $ + Copyright (C) 2012 CoolStream International Ltd This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -20,9 +16,9 @@ $Id: genpsi.c,v 1.2 2006/01/16 12:45:54 sat_man Exp $ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139, USA. - Mit diesem Programm koennen Neutrino TS Streams für das Abspielen unter Enigma gepatched werden + Mit diesem Programm koennen Neutrino TS Streams für das Abspielen unter Enigma gepatched werden */ -//#include + #include #include #include @@ -31,26 +27,15 @@ $Id: genpsi.c,v 1.2 2006/01/16 12:45:54 sat_man Exp $ #define OFS_HDR_2 5 #define OFS_PMT_DATA 13 #define OFS_STREAM_TAB 17 -#define SIZE_STREAM_TAB_ROW 5 +#define SIZE_STREAM_TAB_ROW 5 #define OFS_ENIGMA_TAB 31 -#define SIZE_ENIGMA_TAB_ROW 4 +#define SIZE_ENIGMA_TAB_ROW 4 #define ES_TYPE_MPEG12 0x02 #define ES_TYPE_AVC 0x1b #define ES_TYPE_MPA 0x03 #define ES_TYPE_AC3 0x81 -typedef struct -{ - short nba; - uint16_t vpid; - uint8_t vtype; - uint16_t apid[10]; - short isAC3[10]; -} T_AV_PIDS; - -T_AV_PIDS avPids; - static const uint32_t crc_table[256] = { 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, @@ -97,49 +82,6 @@ static const uint32_t crc_table[256] = { 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 }; -uint32_t calc_crc32psi(uint8_t *dst, const uint8_t *src, uint32_t len) -{ - uint32_t i; - uint32_t crc = 0xffffffff; - - for (i=0; i> 24) ^ *src++) & 0xff]; - - if (dst) - { - dst[0] = (crc >> 24) & 0xff; - dst[1] = (crc >> 16) & 0xff; - dst[2] = (crc >> 8) & 0xff; - dst[3] = (crc) & 0xff; - } - - return crc; -} - -void transfer_pids(uint16_t pid,uint16_t pidart,short isAC3) -{ - switch(pidart) - { - case EN_TYPE_VIDEO: - avPids.vpid=pid; - avPids.vtype = ES_TYPE_MPEG12; - break; - case EN_TYPE_AVC: - avPids.vpid=pid; - avPids.vtype = ES_TYPE_AVC; - break; - case EN_TYPE_AUDIO: - avPids.apid[avPids.nba]=pid; - avPids.isAC3[avPids.nba]=isAC3; - avPids.nba++; - break; - case EN_TYPE_TELTEX: - break; - - default: - break; - } -} //-- special enigma stream description packet for -- //-- at least 1 video, 1 audo and 1 PCR-Pid stream -- //------------------------------------------------------------------------------------ @@ -148,13 +90,13 @@ static uint8_t pkt_enigma[] = 0x47, 0x40, 0x1F, 0x10, 0x00, 0x7F, 0x80, 0x24, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x6D, 0x66, 0x30, 0x19, + 0x00, 0x00, 0x6D, 0x66, 0x30, 0x19, 0x80, 0x13, 'N','E','U','T','R','I','N','O','N','G', // tag(8), len(8), text(10) -> NG hihi ;) 0x00, 0x02, 0x00, 0x6e, // cVPID(8), len(8), PID(16) 0x01, 0x03, 0x00, 0x78, 0x00, // cAPID(8), len(8), PID(16), ac3flag(8) // 0x02, 0x02, 0x00, 0x82,// cTPID(8), len(8), ... 0x03, 0x02, 0x00, 0x6e // cPCRPID(8), ... -}; +}; //-- PAT packet for at least 1 PMT -- //---------------------------------------------------------- static uint8_t pkt_pat[] = @@ -165,25 +107,77 @@ static uint8_t pkt_pat[] = 0x6D, 0x66, 0xEF, 0xFF, // PAT-DATA - PMT (PID=0xFFF) entry }; -//-- PMT packet for at least 1 video and 1 audio stream -- +//-- PMT packet for at least 1 video and 1 audio stream -- //-------------------------------------------------------- static uint8_t pkt_pmt[] = { 0x47, 0x4F, 0xFF, 0x10, 0x00, // HEADER-1 0x02, 0xB0, 0x17, // HEADER-2 0x6D, 0x66, 0xE9, 0x00, 0x00, // HEADER-3 - 0xE0, 0x00, 0xF0, 0x00, // PMT-DATA + 0xE0, 0x00, 0xF0, 0x00, // PMT-DATA 0x02, 0xE0, 0x00, 0xF0, 0x00, // (video stream 1) 0x03, 0xE0, 0x00, 0xF0, 0x00 // (audio stream 1) -}; +}; +CGenPsi::CGenPsi() +{ + nba = 0; + vpid = 0; + vtype = 0; + memset(apid, 0, sizeof(apid)); + memset(atypes, 0, sizeof(atypes)); +} + +uint32_t CGenPsi::calc_crc32psi(uint8_t *dst, const uint8_t *src, uint32_t len) +{ + uint32_t i; + uint32_t crc = 0xffffffff; + + for (i=0; i> 24) ^ *src++) & 0xff]; + + if (dst) + { + dst[0] = (crc >> 24) & 0xff; + dst[1] = (crc >> 16) & 0xff; + dst[2] = (crc >> 8) & 0xff; + dst[3] = (crc) & 0xff; + } + + return crc; +} + +void CGenPsi::addPid(uint16_t pid, uint16_t pidtype, short isAC3) +{ + switch(pidtype) + { + case EN_TYPE_VIDEO: + vpid=pid; + vtype = ES_TYPE_MPEG12; + break; + case EN_TYPE_AVC: + vpid=pid; + vtype = ES_TYPE_AVC; + break; + case EN_TYPE_AUDIO: + apid[nba]=pid; + atypes[nba]=isAC3; + nba++; + break; + case EN_TYPE_TELTEX: + break; + + default: + break; + } +} //== setup a new TS packet with format == //== predefined with a template == //======================================= #define COPY_TEMPLATE(dst, src) copy_template(dst, src, sizeof(src)) -static int copy_template(uint8_t *dst, uint8_t *src, int len) +int CGenPsi::copy_template(uint8_t *dst, uint8_t *src, int len) { //-- reset buffer -- memset(dst, 0xFF, SIZE_TS_PKT); @@ -192,92 +186,93 @@ static int copy_template(uint8_t *dst, uint8_t *src, int len) return len; } -int genpsi(int fd2) + +int CGenPsi::genpsi(int fd) { -// int bytes = 0; uint8_t pkt[SIZE_TS_PKT]; int i, data_len, patch_len, ofs; -//-- copy "Enigma"-template -- + //-- copy "Enigma"-template -- data_len = COPY_TEMPLATE(pkt, pkt_enigma); -//-- adjust len dependent to number of audio streams -- - data_len += ((SIZE_ENIGMA_TAB_ROW+1) * (avPids.nba-1)); + //-- adjust len dependent to number of audio streams -- + data_len += ((SIZE_ENIGMA_TAB_ROW+1) * (nba-1)); patch_len = data_len - OFS_HDR_2 + 1; pkt[OFS_HDR_2+1] |= (patch_len>>8); - pkt[OFS_HDR_2+2] = (patch_len & 0xFF); -//-- write row with desc. for video stream -- + pkt[OFS_HDR_2+2] = (patch_len & 0xFF); + //-- write row with desc. for video stream -- ofs = OFS_ENIGMA_TAB; pkt[ofs] = EN_TYPE_VIDEO; pkt[ofs+1] = 0x02; - pkt[ofs+2] = (avPids.vpid>>8); - pkt[ofs+3] = (avPids.vpid & 0xFF); -//-- for each audio stream, write row with desc. -- - ofs += SIZE_ENIGMA_TAB_ROW; - for (i=0; i>8); + pkt[ofs+3] = (vpid & 0xFF); + //-- for each audio stream, write row with desc. -- + ofs += SIZE_ENIGMA_TAB_ROW; + for (i=0; i>8); - pkt[ofs+3] = (avPids.apid[i] & 0xFF); - pkt[ofs+4] = (avPids.isAC3[i]==1)? 0x01 : 0x00; + pkt[ofs+2] = (apid[i]>>8); + pkt[ofs+3] = (apid[i] & 0xFF); + pkt[ofs+4] = (atypes[i]==1)? 0x01 : 0x00; ofs += (SIZE_ENIGMA_TAB_ROW + 1); } -//-- write row with desc. for pcr stream (eq. video) -- + //-- write row with desc. for pcr stream (eq. video) -- pkt[ofs] = EN_TYPE_PCR; pkt[ofs+1] = 0x02; - pkt[ofs+2] = (avPids.vpid>>8); - pkt[ofs+3] = (avPids.vpid & 0xFF); - -//-- calculate CRC -- - calc_crc32psi(&pkt[data_len], &pkt[OFS_HDR_2], data_len-OFS_HDR_2 ); -//-- write TS packet -- - /*bytes +=*/ write(fd2, pkt, SIZE_TS_PKT); -//-- (II) build PAT -- - data_len = COPY_TEMPLATE(pkt, pkt_pat); -//-- calculate CRC -- - calc_crc32psi(&pkt[data_len], &pkt[OFS_HDR_2], data_len-OFS_HDR_2 ); -//-- write TS packet -- - /*bytes +=*/ write(fd2, pkt, SIZE_TS_PKT); + pkt[ofs+2] = (vpid>>8); + pkt[ofs+3] = (vpid & 0xFF); -//-- (III) build PMT -- + //-- calculate CRC -- + calc_crc32psi(&pkt[data_len], &pkt[OFS_HDR_2], data_len-OFS_HDR_2 ); + //-- write TS packet -- + write(fd, pkt, SIZE_TS_PKT); + + //-- (II) build PAT -- + data_len = COPY_TEMPLATE(pkt, pkt_pat); + //-- calculate CRC -- + calc_crc32psi(&pkt[data_len], &pkt[OFS_HDR_2], data_len-OFS_HDR_2 ); + //-- write TS packet -- + write(fd, pkt, SIZE_TS_PKT); + + //-- (III) build PMT -- data_len = COPY_TEMPLATE(pkt, pkt_pmt); -//-- adjust len dependent to count of audio streams -- - data_len += (SIZE_STREAM_TAB_ROW * (avPids.nba-1)); + //-- adjust len dependent to count of audio streams -- + data_len += (SIZE_STREAM_TAB_ROW * (nba-1)); patch_len = data_len - OFS_HDR_2 + 1; pkt[OFS_HDR_2+1] |= (patch_len>>8); - pkt[OFS_HDR_2+2] = (patch_len & 0xFF); -//-- patch pcr PID -- + pkt[OFS_HDR_2+2] = (patch_len & 0xFF); + //-- patch pcr PID -- ofs = OFS_PMT_DATA; - pkt[ofs] |= (avPids.vpid>>8); - pkt[ofs+1] = (avPids.vpid & 0xFF); -//-- write row with desc. for ES video stream -- + pkt[ofs] |= (vpid>>8); + pkt[ofs+1] = (vpid & 0xFF); + //-- write row with desc. for ES video stream -- ofs = OFS_STREAM_TAB; - pkt[ofs] = avPids.vtype; - pkt[ofs+1] = 0xE0 | (avPids.vpid>>8); - pkt[ofs+2] = (avPids.vpid & 0xFF); + pkt[ofs] = vtype; + pkt[ofs+1] = 0xE0 | (vpid>>8); + pkt[ofs+2] = (vpid & 0xFF); pkt[ofs+3] = 0xF0; pkt[ofs+4] = 0x00; -//-- for each ES audio stream, write row with desc. -- - for (i=0; i>8); - pkt[ofs+2] = (avPids.apid[i] & 0xFF); + pkt[ofs] = (atypes[i]==1)? ES_TYPE_AC3 : ES_TYPE_MPA; + pkt[ofs+1] = 0xE0 | (apid[i]>>8); + pkt[ofs+2] = (apid[i] & 0xFF); pkt[ofs+3] = 0xF0; pkt[ofs+4] = 0x00; } -//-- calculate CRC -- + //-- calculate CRC -- calc_crc32psi(&pkt[data_len], &pkt[OFS_HDR_2], data_len-OFS_HDR_2 ); -//-- write TS packet -- - /*bytes +=*/ write(fd2, pkt, SIZE_TS_PKT); -//-- finish -- - avPids.vpid=0; - avPids.nba=0; - fdatasync(fd2); + //-- write TS packet -- + write(fd, pkt, SIZE_TS_PKT); + //-- finish -- + vpid=0; + nba=0; + fdatasync(fd); return 1; } diff --git a/src/driver/genpsi.h b/src/driver/genpsi.h index 113eb883b..3e5c0a051 100644 --- a/src/driver/genpsi.h +++ b/src/driver/genpsi.h @@ -1,10 +1,7 @@ /* -$Id: genpsi.h,v 1.1 2005/08/15 14:47:52 metallica Exp $ Copyright (c) 2004 gmo18t, Germany. All rights reserved. - - aktuelle Versionen gibt es hier: - $Source: /cvs/tuxbox/apps/tuxbox/neutrino/src/driver/genpsi.h,v $ + Copyright (C) 2012 CoolStream International Ltd This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -26,13 +23,26 @@ $Id: genpsi.h,v 1.1 2005/08/15 14:47:52 metallica Exp $ #define __genpsi_h__ #include -int genpsi(int fd2); -void transfer_pids(uint16_t pid,uint16_t pidart,short isAC3); - #define EN_TYPE_VIDEO 0x00 #define EN_TYPE_AUDIO 0x01 #define EN_TYPE_TELTEX 0x02 #define EN_TYPE_PCR 0x03 #define EN_TYPE_AVC 0x04 +class CGenPsi +{ + private: + short nba; + uint16_t vpid; + uint8_t vtype; + uint16_t apid[10]; + short atypes[10]; + static int copy_template(uint8_t *dst, uint8_t *src, int len); + uint32_t calc_crc32psi(uint8_t *dst, const uint8_t *src, uint32_t len); + + public: + CGenPsi(); + void addPid(uint16_t pid,uint16_t pidtype, short isAC3); + int genpsi(int fd); +}; #endif From 0578ef7c30de232035f603036694f48aaf19f9d1 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 8 Nov 2012 15:08:41 +0400 Subject: [PATCH 47/64] driver/Makefile.am: replace genpsi.c with genpsi.cpp --- src/driver/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index 617c4be36..1216726f1 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -26,7 +26,7 @@ libneutrino_driver_a_SOURCES = \ file.cpp \ fontrenderer.cpp \ framebuffer.cpp \ - genpsi.c \ + genpsi.cpp \ radiotext.cpp \ radiotools.cpp \ rcinput.cpp \ From 2b0f9efbc80e95ae193576e511dfaf65587e4dec Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 8 Nov 2012 15:09:10 +0400 Subject: [PATCH 48/64] driver/record.cpp: use CGenPsi class --- src/driver/record.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/driver/record.cpp b/src/driver/record.cpp index ae2567723..2d1134e54 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -156,15 +156,16 @@ record_error_msg_t CRecordInstance::Start(CZapitChannel * channel) return RECORD_INVALID_DIRECTORY; } + CGenPsi psi; if (allpids.PIDs.vpid != 0) - transfer_pids(allpids.PIDs.vpid, recMovieInfo->VideoType ? EN_TYPE_AVC : EN_TYPE_VIDEO, 0); + psi.addPid(allpids.PIDs.vpid, recMovieInfo->VideoType ? EN_TYPE_AVC : EN_TYPE_VIDEO, 0); numpids = 0; for (unsigned int i = 0; i < recMovieInfo->audioPids.size(); i++) { apids[numpids++] = recMovieInfo->audioPids[i].epgAudioPid; - transfer_pids(recMovieInfo->audioPids[i].epgAudioPid, EN_TYPE_AUDIO, recMovieInfo->audioPids[i].atype); + psi.addPid(recMovieInfo->audioPids[i].epgAudioPid, EN_TYPE_AUDIO, recMovieInfo->audioPids[i].atype); } - genpsi(fd); + psi.genpsi(fd); if ((StreamVTxtPid) && (allpids.PIDs.vtxtpid != 0)) apids[numpids++] = allpids.PIDs.vtxtpid; From 299e20387d96ff8f70905af75cf97c60446841da Mon Sep 17 00:00:00 2001 From: satbaby Date: Thu, 8 Nov 2012 12:24:23 +0100 Subject: [PATCH 49/64] src/neutrino.cpp: -add lockStandbyCall --- src/neutrino.cpp | 7 +++++++ src/neutrino.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 42919c114..06d015cf3 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -207,6 +207,7 @@ CNeutrinoApp::CNeutrinoApp() RADIOchannelList = NULL; skipShutdownTimer = false; skipSleepTimer = false; + lockStandbyCall = false; current_muted = 0; recordingstatus = 0; g_channel_list_changed = 0; @@ -3079,6 +3080,11 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) //static bool wasshift = false; INFO("%s", bOnOff ? "ON" : "OFF" ); + if(lockStandbyCall) + return; + + lockStandbyCall = true; + if( bOnOff ) { if( mode == mode_scart ) { //g_Controld->setScartMode( 0 ); @@ -3207,6 +3213,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) g_volume->AudioMute(current_muted, true); StartSubtitles(); } + lockStandbyCall = false; } void CNeutrinoApp::radioMode( bool rezap) diff --git a/src/neutrino.h b/src/neutrino.h index b129adfe6..c36dd2406 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -119,6 +119,7 @@ private: bool skipShutdownTimer; bool skipSleepTimer; + bool lockStandbyCall; bool pbBlinkChange; int tvsort[LIST_MODE_LAST]; int radiosort[LIST_MODE_LAST]; From a47c6593dc98faa2c26a14aeaf2961a006f3487e Mon Sep 17 00:00:00 2001 From: satbaby Date: Thu, 8 Nov 2012 13:35:00 +0100 Subject: [PATCH 50/64] neutrino: -add save epg on stadbyOn/Off option --- data/locale/deutsch.locale | 2 ++ data/locale/english.locale | 2 ++ src/gui/miscsettings_menu.cpp | 4 ++++ src/neutrino.cpp | 5 +++-- src/system/locals.h | 2 ++ src/system/locals_intern.h | 2 ++ src/system/settings.h | 1 + 7 files changed, 16 insertions(+), 2 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 0d1ab625b..817e3c5e0 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -749,6 +749,7 @@ menu.hint_epg_fonts Ändern Sie für die EPG-Details die Schriftgrößen menu.hint_epg_max_events Maximum an Events im Zwischenspeicher. Nach Erreichen der\nGrenze werden EPG-Daten für zukünftige gelöscht menu.hint_epg_old_events EPG im Speicher behalten in Stunden,\nauch wenn es veraltet ist menu.hint_epg_save Speichert die EPG-Daten auf einer Harddisk oder USB-Stick\nund läd es nach einen Neustart +menu.hint_epg_save_standby Speichert die EPG-Daten in Bereitschaft Modus menu.hint_event_textcolor Ändern Sie die Event-Farbe für farbige Event-Optionen in Kanalliste und Infobar menu.hint_eventlist_fonts Ändern Sie in der Event-Liste die Schriftgrößen menu.hint_extended Energiespar-, EPG-Speicher- / Lade-Optionen,\nHDMI-CEC, Startkanal, Zap-Optionen @@ -1100,6 +1101,7 @@ miscsettings.epg_old_events EPG verwerfen nach (Std.) miscsettings.epg_old_events_hint1 Wie lange abgelaufene EPG-Daten aufheben? miscsettings.epg_old_events_hint2 Angabe in Stunden miscsettings.epg_save EPG zwischenspeichern +miscsettings.epg_save_standby EPG speichern in Standby-Modus miscsettings.general Allgemein miscsettings.head Erweitert miscsettings.infobar Infobar diff --git a/data/locale/english.locale b/data/locale/english.locale index 48bad20a2..eb24ddc23 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -749,6 +749,7 @@ menu.hint_epg_fonts Change EPG details window font sizes menu.hint_epg_max_events Maximum events to cache. After reaching limit\nEPG cache will remove future events menu.hint_epg_old_events Hours after event end time to consider\nevent old and remove it from cache menu.hint_epg_save Save cached EPG to harddisk or usb flash\nand load it after boot +menu.hint_epg_save_standby Save EPG on soft standby mode menu.hint_event_textcolor Change event color for colored-event options\nin channel list and infobar menu.hint_eventlist_fonts Change event list font sizes menu.hint_extended Power saving, EPG save/load options\nHDMI-CEC, Start channel, zap options @@ -1100,6 +1101,7 @@ miscsettings.epg_old_events EPG remove after (std.) miscsettings.epg_old_events_hint1 How long will EPG-Data be stored after they timed out? miscsettings.epg_old_events_hint2 Set in hours miscsettings.epg_save Save/Restore epg on reboot +miscsettings.epg_save_standby Save epg on soft standby miscsettings.general General miscsettings.head Extended settings miscsettings.infobar Infobar diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index af9c630ed..8f0d0acde 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -307,6 +307,10 @@ void CMiscMenue::showMiscSettingsMenuEpg(CMenuWidget *ms_epg) mc->setHint("", LOCALE_MENU_HINT_EPG_SAVE); ms_epg->addItem(mc); + CMenuOptionChooser * mc1 = new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SAVE_STANDBY, &g_settings.epg_save_standby, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); + mc1->setHint("", LOCALE_MENU_HINT_EPG_SAVE_STANDBY); + ms_epg->addItem(mc1); + CStringInput * miscSettings_epg_cache = new CStringInput(LOCALE_MISCSETTINGS_EPG_CACHE, &g_settings.epg_cache, 2,LOCALE_MISCSETTINGS_EPG_CACHE_HINT1, LOCALE_MISCSETTINGS_EPG_CACHE_HINT2 , "0123456789 ", sectionsdConfigNotifier); CMenuForwarder * mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_CACHE, true, g_settings.epg_cache, miscSettings_epg_cache); mf->setHint("", LOCALE_MENU_HINT_EPG_CACHE); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 06d015cf3..edbdde21e 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -424,7 +424,7 @@ int CNeutrinoApp::loadSetup(const char * fname) snprintf(g_settings.ifname, sizeof(g_settings.ifname), "%s", configfile.getString("ifname", "eth0").c_str());; g_settings.epg_save = configfile.getBool("epg_save", false); - + g_settings.epg_save_standby = configfile.getBool("epg_save_standby", true); //widget settings g_settings.widget_fade = false; g_settings.widget_fade = configfile.getBool("widget_fade" , false ); @@ -864,6 +864,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setString("timezone", g_settings.timezone); // epg configfile.setBool("epg_save", g_settings.epg_save); + configfile.setBool("epg_save_standby", g_settings.epg_save_standby); configfile.setString("epg_cache_time" ,g_settings.epg_cache ); configfile.setString("epg_extendedcache_time" ,g_settings.epg_extendedcache); configfile.setString("epg_old_events" ,g_settings.epg_old_events ); @@ -3120,7 +3121,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) if(!CRecordManager::getInstance()->RecordingStatus() ) { //only save epg when not recording - if(g_settings.epg_save && !fromDeepStandby) { + if(g_settings.epg_save && !fromDeepStandby && g_settings.epg_save_standby) { saveEpg(false);//false CVFD::MODE_STANDBY } } diff --git a/src/system/locals.h b/src/system/locals.h index 73aeb3603..6808a23f9 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -776,6 +776,7 @@ typedef enum LOCALE_MENU_HINT_EPG_MAX_EVENTS, LOCALE_MENU_HINT_EPG_OLD_EVENTS, LOCALE_MENU_HINT_EPG_SAVE, + LOCALE_MENU_HINT_EPG_SAVE_STANDBY, LOCALE_MENU_HINT_EVENT_TEXTCOLOR, LOCALE_MENU_HINT_EVENTLIST_FONTS, LOCALE_MENU_HINT_EXTENDED, @@ -1127,6 +1128,7 @@ typedef enum LOCALE_MISCSETTINGS_EPG_OLD_EVENTS_HINT1, LOCALE_MISCSETTINGS_EPG_OLD_EVENTS_HINT2, LOCALE_MISCSETTINGS_EPG_SAVE, + LOCALE_MISCSETTINGS_EPG_SAVE_STANDBY, LOCALE_MISCSETTINGS_GENERAL, LOCALE_MISCSETTINGS_HEAD, LOCALE_MISCSETTINGS_INFOBAR, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index ede893246..47161f20e 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -776,6 +776,7 @@ const char * locale_real_names[] = "menu.hint_epg_max_events", "menu.hint_epg_old_events", "menu.hint_epg_save", + "menu.hint_epg_save_standby", "menu.hint_event_textcolor", "menu.hint_eventlist_fonts", "menu.hint_extended", @@ -1127,6 +1128,7 @@ const char * locale_real_names[] = "miscsettings.epg_old_events_hint1", "miscsettings.epg_old_events_hint2", "miscsettings.epg_save", + "miscsettings.epg_save_standby", "miscsettings.general", "miscsettings.head", "miscsettings.infobar", diff --git a/src/system/settings.h b/src/system/settings.h index cbb7b0c25..2ca0ddd42 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -123,6 +123,7 @@ struct SNeutrinoSettings // EPG int epg_save; + int epg_save_standby; std::string epg_cache; std::string epg_old_events; std::string epg_max_events; From ae6cbc9479434005562371c669a7f9f78a04168c Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 8 Nov 2012 19:10:37 +0400 Subject: [PATCH 51/64] driver/streamts.cpp: replace old code with class, support multi-client and multi-channel, experimental / testing - please read comments at the top of driver/streamts.cpp --- src/driver/streamts.cpp | 820 ++++++++++++++++++++++------------------ src/driver/streamts.h | 96 +++++ 2 files changed, 555 insertions(+), 361 deletions(-) create mode 100644 src/driver/streamts.h diff --git a/src/driver/streamts.cpp b/src/driver/streamts.cpp index afeebd388..0e3142c5c 100644 --- a/src/driver/streamts.cpp +++ b/src/driver/streamts.cpp @@ -1,3 +1,29 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2011-2012 CoolStream International Ltd + + based on code which is + Copyright (C) 2002 Andreas Oberritter + Copyright (C) 2001 TripleDES + Copyright (C) 2000, 2001 Marcus Metzler + + License: GPLv2 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + #include #include #include @@ -13,10 +39,8 @@ #include #include -/* work around for building with old kernel headers */ -#ifndef POLLRDHUP -#define POLLRDHUP 0 -#endif +#include +#include #ifdef HAVE_CONFIG_H #include @@ -28,248 +52,231 @@ #include #include #include +#include +#include +#include +#include +/* experimental mode: + * stream not possible, if record running + * pids in url ignored, and added from channel, with fake PAT/PMT + * different channels supported, only from the same transponder - no zap is done, + * with url like http://coolstream:31339/id=c32400030070283e (channel id) + * TODO: multi-tuner support + */ +#define ENABLE_MULTI_CHANNEL #define TS_SIZE 188 -#define IN_SIZE (2048 * TS_SIZE) -//#define IN_SIZE (TS_SIZE * 362) +#define DMX_BUFFER_SIZE (2048*TS_SIZE) +#define IN_SIZE (250*TS_SIZE) -#define DMX_BUFFER_SIZE (2 * 3008 * 62) - -/* maximum number of pes pids */ -#define MAXPIDS 64 - -/* tcp packet data size */ -//#define PACKET_SIZE 1448 -#define PACKET_SIZE 7*TS_SIZE - -//unsigned char * buf; - -extern CCam *cam0; - -//int demuxfd[MAXPIDS]; - -static unsigned char exit_flag = 0; -static unsigned int writebuf_size = 0; -static unsigned char writebuf[PACKET_SIZE]; - -void packet_stdout (int fd, unsigned char * buf, int count, void * /*p*/) +CStreamInstance::CStreamInstance(int clientfd, t_channel_id chid, stream_pids_t &_pids) { - - unsigned int size; - unsigned char * bp; - ssize_t written; - -//printf("packet_stdout count %d\n", count); - /* ensure, that there is always at least one complete - * packet inside of the send buffer */ - while (writebuf_size + count >= PACKET_SIZE) { - - /* how many bytes are to be sent from the input buffer? */ - size = PACKET_SIZE - writebuf_size; - - /* send buffer is not empty, so copy from - input buffer to get a complete packet */ - if (writebuf_size) { - memmove(writebuf + writebuf_size, buf, size); - bp = writebuf; - } - - /* if send buffer is empty, then do not memcopy, - but send directly from input buffer */ - else { - bp = buf; - } - - /* write the packet, count the amount of really written bytes */ - written = write(fd, bp, PACKET_SIZE); - - /* exit on error */ - if (written == -1) { - perror("write"); - exit_flag = 1; - return; - } - - /* if the packet could not be written completely, then - * how many bytes must be stored in the send buffer - * until the next packet is to be sent? */ - writebuf_size = PACKET_SIZE - written; - - /* move all bytes of the packet which were not sent - * to the beginning of the send buffer */ - if (writebuf_size) - memmove(writebuf, bp + written, writebuf_size); - - /* * advance in the input buffer */ - buf += size; - - /* * decrease the todo size */ - count -= size; - } - - /* if there are still some bytes left in the input buffer, - * then store them in the send buffer and increase send - * buffer size */ - if (count) { - memmove(writebuf + writebuf_size, buf, count); - writebuf_size += count; - } + printf("CStreamInstance:: new channel %llx fd %d\n", chid, clientfd); + fds.insert(clientfd); + pids = _pids; + channel_id = chid; + running = false; + dmx = NULL; + buf = NULL; } -int open_incoming_port (int port) +CStreamInstance::~CStreamInstance() { - struct sockaddr_in socketAddr; - int socketOptActive = 1; - int handle; - - if (!port) - return -1; - - if ((handle = socket (AF_INET, SOCK_STREAM, 0)) < 0) - { - fprintf (stderr, "network port %u open: ", port); - perror ("socket"); - return -1; - } - - if (setsockopt (handle, SOL_SOCKET, SO_REUSEADDR, (const void *)&socketOptActive, sizeof (int)) < 0) - { - fprintf (stderr, "network port %u open: error setsockopt\n", port); - close (handle); - return -1; - } - - socketAddr.sin_family = AF_INET; - socketAddr.sin_port = htons (port); - socketAddr.sin_addr.s_addr = htonl (INADDR_ANY); - - if (bind (handle, (struct sockaddr *) &socketAddr, sizeof (socketAddr)) < 0) - { - fprintf (stderr, "network port %u open: ", port); - perror ("bind"); - close (handle); - return -1; - } - - if (listen (handle, 5) < 0) - { - fprintf (stderr, "network port %u open: ", port); - perror ("listen"); - close (handle); - return -1; - } - return handle; + Stop(); + Close(); } -void * streamts_live_thread(void *data); -int streamts_stop; - -void streamts_main_thread(void * /*data*/) +bool CStreamInstance::Start() { - struct sockaddr_in servaddr; - int clilen; + if (running) + return false; - struct pollfd pfd[128]; - int poll_cnt, tcnt; - int listenfd; - int connfd = -1; - int pollres; - int i; - pthread_t st = 0; - - printf("Starting STREAM thread keeper, tid %ld\n", syscall(__NR_gettid)); - - listenfd = open_incoming_port(31339); - if(listenfd < 0) { - printf("Open incoming port failed\n"); - return; + buf = new unsigned char [IN_SIZE]; + if (buf == NULL) { + perror("CStreamInstance::Start: buf"); + return false; } - printf("listenfd %d\n", listenfd); - - clilen = sizeof (servaddr); - pfd[0].fd = listenfd; - pfd[0].events = (POLLIN | POLLPRI); - pfd[0].revents = 0; - tcnt = 1; - streamts_stop = 0; - - while (!streamts_stop) { - poll_cnt = tcnt; -//printf("polling, count= %d\n", poll_cnt); - pollres = poll (pfd, poll_cnt, 1000); - if (pollres < 0) { - perror("streamts_main_thread poll"); - continue; - } - if(pollres == 0) - continue; - for (i = poll_cnt - 1; i >= 0; i--) { - if (pfd[i].revents & (POLLIN | POLLPRI | POLLHUP | POLLRDHUP)) { - printf("fd %d has events %x\n", pfd[i].fd, pfd[i].revents); - if (pfd[i].fd == listenfd) { - connfd = accept (listenfd, (struct sockaddr *) &servaddr, (socklen_t *) & clilen); - printf("new connection, fd %d\n", connfd); - if(connfd < 0) { - perror("accept"); - continue; - } - if(st != 0) { - printf("New connection, stopping stream thread\n"); - exit_flag = 1; - pthread_join(st, NULL); - tcnt --; - } - pfd[tcnt].fd = connfd; - pfd[tcnt].events = POLLRDHUP | POLLHUP; - pfd[tcnt].revents = 0; - tcnt++; - exit_flag = 0; - pthread_create (&st, NULL, streamts_live_thread, (void *) connfd); - } else { - if (pfd[i].revents & (POLLHUP | POLLRDHUP)) { - connfd = -1; - printf("Client disconnected, stopping stream thread\n"); - exit_flag = 1; - if(st) - pthread_join(st, NULL); - st = 0; - tcnt --; - } - } - } - } - } - printf("Stopping STREAM thread keeper\n"); - close(listenfd); - if(st != 0) { - printf("Stopping stream thread\n"); - exit_flag = 1; - pthread_join(st, NULL); - close(connfd); - } - return; + running = true; + printf("CStreamInstance::Start: %llx\n", channel_id); + return (OpenThreads::Thread::start() == 0); } -void * streamts_live_thread(void *data) +bool CStreamInstance::Stop() +{ + if (!running) + return false; + + printf("CStreamInstance::Stop: %llx\n", channel_id); + running = false; + return (OpenThreads::Thread::join() == 0); +} + +bool CStreamInstance::Send(ssize_t r) +{ + mutex.lock(); + for (stream_fds_t::iterator it = fds.begin(); it != fds.end(); ++it) { + int ret, i = 10; + do { + ret = send(*it, buf, r, MSG_DONTWAIT); +#if 0 + if (ret != r) + usleep(100); +#endif + } while ((ret != r) && (i-- > 0)); + if (ret != r) { + if (r < 0) + perror("send"); + printf("send err, fd %d: %d\n", *it, r); + } + } + mutex.unlock(); + return true; +} + +void CStreamInstance::Close() +{ + for (stream_fds_t::iterator fit = fds.begin(); fit != fds.end(); ++fit) + close(*fit); + fds.clear(); +} + +void CStreamInstance::AddClient(int clientfd) +{ + mutex.lock(); + fds.insert(clientfd); + printf("CStreamInstance::AddClient: %d (count %d)\n", clientfd, fds.size()); + mutex.unlock(); +} + +void CStreamInstance::RemoveClient(int clientfd) +{ + mutex.lock(); + fds.erase(clientfd); + close(clientfd); + printf("CStreamInstance::RemoveClient: %d (count %d)\n", clientfd, fds.size()); + mutex.unlock(); +} + +void CStreamInstance::run() +{ + printf("CStreamInstance::run: %llx\n", channel_id); + + dmx = new cDemux(STREAM_DEMUX);//FIXME + + dmx->Open(DMX_TP_CHANNEL, NULL, DMX_BUFFER_SIZE); + + /* pids here cannot be empty */ + stream_pids_t::iterator it = pids.begin(); + printf("CStreamInstance::run: add pid %x\n", *it); + dmx->pesFilter(*it); + ++it; + for (; it != pids.end(); ++it) { + printf("CStreamInstance::run: add pid %x\n", *it); + dmx->addPid(*it); + } +#ifdef ENABLE_MULTI_CHANNEL + dmx->Start();//FIXME +#else + dmx->Start(true);//FIXME +#endif + + CCamManager::getInstance()->Start(channel_id, CCamManager::STREAM); + + while (running) { + ssize_t r = dmx->Read(buf, IN_SIZE, 100); + if(r > 0) + Send(r); + } + + CCamManager::getInstance()->Stop(channel_id, CCamManager::STREAM); + + printf("CStreamInstance::run: exiting %llx (%d fds)\n", channel_id, fds.size()); + + Close(); + delete dmx; + delete []buf; +} + +bool CStreamInstance::HasFd(int fd) +{ + if (fds.find(fd) != fds.end()) + return true; + return false; +} + +/************************************************************************/ +CStreamManager *CStreamManager::sm = NULL; +CStreamManager::CStreamManager() +{ + enabled = true; + running = false; + listenfd = -1; + port = 31339; +} + +CStreamManager::~CStreamManager() +{ + Stop(); +} + +CStreamManager * CStreamManager::getInstance() +{ + if (sm == NULL) + sm = new CStreamManager(); + return sm; +} + +bool CStreamManager::Start(int _port) +{ + if (running) + return false; + + if (_port) + port = _port; + if (!Listen()) + return false; + + running = true; + return (OpenThreads::Thread::start() == 0); +} + +bool CStreamManager::Stop() +{ + if (!running) + return false; + running = false; + return (OpenThreads::Thread::join() == 0); +} + +bool CStreamManager::SetPort(int newport) +{ + bool ret = false; + if (port != newport) { + port = newport; +#if 0 + Stop(); + ret = Start(newport); +#endif + mutex.lock(); + if (listenfd >= 0) + close(listenfd); + ret = Listen(); + mutex.unlock(); + } + return ret; +} + +bool CStreamManager::Parse(int fd, stream_pids_t &pids, t_channel_id &chid) { - unsigned char * buf; - int pid; - int pids[MAXPIDS]; char cbuf[512]; char *bp; - int fd = (int) data; - unsigned char demuxfd_count = 0; - printf("Starting LIVE STREAM thread, fd %d\n", fd); FILE * fp = fdopen(fd, "r+"); if(fp == NULL) { perror("fdopen"); - return 0; + return false; } - - writebuf_size = 0; - cbuf[0] = 0; bp = &cbuf[0]; @@ -279,7 +286,7 @@ void * streamts_live_thread(void *data) int res = read(fd, &c, 1); if(res < 0) { perror("read"); - return 0; + return false; } if ((*bp++ = c) == '\n') break; @@ -288,7 +295,7 @@ void * streamts_live_thread(void *data) *bp++ = 0; bp = &cbuf[0]; - printf("stream: got %s\n", cbuf); + printf("CStreamManager::Parse: got %s\n", cbuf); /* send response to http client */ if (!strncmp(cbuf, "GET /", 5)) { @@ -297,165 +304,256 @@ void * streamts_live_thread(void *data) bp += 5; } else { printf("Received garbage\n"); - return 0; + return false; } +#ifndef ENABLE_MULTI_CHANNEL /* parse stdin / url path, start dmx filters */ do { + int pid; int res = sscanf(bp, "%x", &pid); if(res == 1) { printf("New pid: 0x%x\n", pid); - pids[demuxfd_count++] = pid; + pids.insert(pid); } } - while ((bp = strchr(bp, ',')) && (bp++) && (demuxfd_count < MAXPIDS)); + while ((bp = strchr(bp, ',')) && (bp++)); +#endif - if(demuxfd_count == 0) { - printf("No pids!\n"); - CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel(); + chid = CZapit::getInstance()->GetCurrentChannelID(); + CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel(); + + int mode = CNeutrinoApp::getInstance()->getMode(); + if (mode == NeutrinoMessages::mode_standby && streams.empty()) { + printf("CStreamManager::Parse: wakeup zapit..\n"); + g_Zapit->setStandby(false); + g_Zapit->getMode(); + } + if(pids.empty()) { +#ifdef ENABLE_MULTI_CHANNEL + t_channel_id tmpid; + bp = &cbuf[5]; + if (sscanf(bp, "id=%llx", &tmpid) == 1) { + printf("############################# channel_id %llx\n", tmpid); + + CZapitChannel * tmpchan = CServiceManager::getInstance()->FindChannel(tmpid); + if (tmpchan && (tmpid != chid) && SAME_TRANSPONDER(tmpid, chid)) { + printf("############################# channel_id %llx -> zap\n", tmpid); + bool ret = g_Zapit->zapTo_record(tmpid) > 0; + if (ret) { + channel = tmpchan; + chid = tmpid; + } + } + } + if(CRecordManager::getInstance()->RecordingStatus(tmpid)) { + printf("CStreamManager::Parse: channel %llx recorded, aborting..\n", tmpid); + return false; + } +#endif + + printf("CStreamManager::Parse: no pids in url, using channel %llx pids\n", chid); if(!channel) - return 0; - pids[demuxfd_count++] = 0; - pids[demuxfd_count++] = channel->getPmtPid(); - pids[demuxfd_count++] = channel->getVideoPid(); + return false; + //pids.insert(0); + //pids.insert(channel->getPmtPid()); + pids.insert(channel->getVideoPid()); for (int i = 0; i < channel->getAudioChannelCount(); i++) - pids[demuxfd_count++] = channel->getAudioChannel(i)->pid; + pids.insert(channel->getAudioChannel(i)->pid); } - - buf = new unsigned char [IN_SIZE]; - if (buf == NULL) { - perror("NEW"); - return 0; + CGenPsi psi; + for (stream_pids_t::iterator it = pids.begin(); it != pids.end(); ++it) { + if (*it == channel->getVideoPid()) { + printf("CStreamManager::Parse: genpsi vpid %x (%d)\n", *it, channel->type); + psi.addPid(*it, channel->type ? EN_TYPE_AVC : EN_TYPE_VIDEO, 0); + } else { + for (int i = 0; i < channel->getAudioChannelCount(); i++) { + if (*it == channel->getAudioChannel(i)->pid) { + CZapitAudioChannel::ZapitAudioChannelType atype = channel->getAudioChannel(i)->audioChannelType; + printf("CStreamManager::Parse: genpsi apid %x (%d)\n", *it, atype); + psi.addPid(*it, EN_TYPE_AUDIO, atype); + } + } + } } + psi.genpsi(fd); - cDemux * dmx = new cDemux(STREAM_DEMUX);//FIXME - - dmx->Open(DMX_TP_CHANNEL, NULL, DMX_BUFFER_SIZE); - - dmx->pesFilter(pids[0]); - for(int i = 1; i < demuxfd_count; i++) - dmx->addPid(pids[i]); - - dmx->Start(true);//FIXME - - CCamManager::getInstance()->Start(CZapit::getInstance()->GetCurrentChannelID(), CCamManager::STREAM); - ssize_t r; - - while (!exit_flag) { - r = dmx->Read(buf, IN_SIZE, 100); - if(r > 0) - packet_stdout(fd, buf, r, NULL); - } - - printf("Exiting LIVE STREAM thread, fd %d\n", fd); - - CCamManager::getInstance()->Stop(CZapit::getInstance()->GetCurrentChannelID(), CCamManager::STREAM); - - delete dmx; - delete []buf; - close(fd); - return 0; + return !pids.empty(); } -#if 0 -//never used -void streamts_file_thread(void *data) + +void CStreamManager::run() { - int dvrfd; - unsigned char * buf; - char cbuf[512]; - char *bp; - unsigned char mode = 0; - char tsfile[IN_SIZE]; - int tsfilelen = 0; - int fileslice = 0; - int i = 0; - int fd = (int) data; + struct sockaddr_in servaddr; + int clilen = sizeof(servaddr);; - buf = (unsigned char *) malloc(IN_SIZE); + struct pollfd pfd[128]; + int poll_cnt; - if (buf == NULL) { - perror("malloc"); - return; - } + printf("Starting STREAM thread keeper, tid %ld\n", syscall(__NR_gettid)); - bp = &cbuf[0]; - - /* read one line */ - while (bp - &cbuf[0] < IN_SIZE) { - unsigned char c; - read(fd, &c, 1); - if ((*bp++ = c) == '\n') - break; - } - - *bp++ = 0; - bp = &cbuf[0]; - - /* send response to http client */ - if (!strncmp(cbuf, "GET /", 5)) { - printf("HTTP/1.1 200 OK\r\nServer: streamts (%s)\r\n\r\n", "ts" /*&argv[1][1]*/); - fflush(stdout); - bp += 5; - } - - /* ts filename */ - int j = 0; - i = 0; - while (i < (int) strlen(bp) - 3) - { - if ((bp[i] == '.') && (bp[i + 1] == 't') && (bp[i + 2] == 's')) - { - tsfile[j] = bp[i]; - tsfile[j + 1] = bp[i + 1]; - tsfile[j + 2] = bp[i + 2]; - tsfile[j + 3] = '\0'; - break; - } - else - if ((bp[i] == '%') && (bp[i + 1] == '2') && (bp[i + 2] == '0')) - { - tsfile[j++] = ' '; - i += 3; + while (running) { + mutex.lock(); + pfd[0].fd = listenfd; + pfd[0].events = (POLLIN | POLLPRI); + pfd[0].revents = 0; + poll_cnt = 1; + for (streammap_iterator_t it = streams.begin(); it != streams.end(); ++it) { + stream_fds_t fds = it->second->GetFds(); + for (stream_fds_t::iterator fit = fds.begin(); fit != fds.end(); ++fit) { + pfd[poll_cnt].fd = *fit; + pfd[poll_cnt].events = POLLRDHUP | POLLHUP; + pfd[poll_cnt].revents = 0; + poll_cnt++; } - else - tsfile[j++] = bp[i++]; - } - tsfilelen = strlen(tsfile); - /* open ts file */ - if ((dvrfd = open(tsfile, O_RDONLY)) < 0) { - free(buf); - return; - } - - size_t pos; - ssize_t r; - - while (!exit_flag) { - /* always read IN_SIZE bytes */ - for (pos = 0; pos < IN_SIZE; pos += r) { - r = read(dvrfd, buf + pos, IN_SIZE - pos); - if (r == -1) { - /* Error */ - exit_flag = 1; - break; - } else if (r == 0) { - /* End of file */ - if (mode == 3) { - close(dvrfd); - sprintf(&tsfile[tsfilelen], ".%03d", ++fileslice); - dvrfd = open(tsfile, O_RDONLY); - } - if ((dvrfd == -1) || (mode != 3)) { - exit_flag = 1; - break; + } + mutex.unlock(); +//printf("polling, count= %d\n", poll_cnt); + int pollres = poll (pfd, poll_cnt, 1000); + if (pollres < 0) { + perror("CStreamManager::run(): poll"); + continue; + } + if(pollres == 0) + continue; + for (int i = poll_cnt - 1; i >= 0; i--) { + if (pfd[i].revents & (POLLIN | POLLPRI | POLLHUP | POLLRDHUP)) { + printf("fd %d has events %x\n", pfd[i].fd, pfd[i].revents); + if (pfd[i].fd == listenfd) { + int connfd = accept (listenfd, (struct sockaddr *) &servaddr, (socklen_t *) & clilen); + printf("CStreamManager::run(): connection, fd %d\n", connfd); + if(connfd < 0) { + perror("CStreamManager::run(): accept"); + continue; + } + stream_pids_t pids; + t_channel_id channel_id; + if (Parse(connfd, pids, channel_id)) { + mutex.lock(); + streammap_iterator_t it = streams.find(channel_id); + if (it != streams.end()) { + it->second->AddClient(connfd); + } else { + CStreamInstance * stream = new CStreamInstance(connfd, channel_id, pids); + if (stream->Start()) + streams.insert(streammap_pair_t(channel_id, stream)); + else + delete stream; + } + mutex.unlock(); + } else { + close(connfd); + } + } else { + if (pfd[i].revents & (POLLHUP | POLLRDHUP)) { + printf("CStreamManager::run(): POLLHUP, fd %d\n", pfd[i].fd); + mutex.lock(); + for (streammap_iterator_t it = streams.begin(); it != streams.end(); ++it) { + if (it->second->HasFd(pfd[i].fd)) { + CStreamInstance *stream = it->second; + stream->RemoveClient(pfd[i].fd); + if (stream->GetFds().empty()) { + streams.erase(stream->GetChannelId()); + delete stream; + } + break; + } + } + mutex.unlock(); + } } } } - packet_stdout(fd, buf, pos, NULL); } - close(dvrfd); - free(buf); - - return; + printf("CStreamManager::run: stopping...\n"); + close(listenfd); + listenfd = -1; + StopAll(); +} + +bool CStreamManager::StopAll() +{ + bool ret = !streams.empty(); + for (streammap_iterator_t it = streams.begin(); it != streams.end(); ++it) { + it->second->Stop(); + delete it->second; + } + streams.clear(); + return ret; +} + +bool CStreamManager::StopStream(t_channel_id channel_id) +{ + bool ret = false; + mutex.lock(); + if (channel_id) { + streammap_iterator_t it = streams.find(channel_id); + if (it != streams.end()) { + delete it->second; + streams.erase(channel_id); + ret = true; + } + } else { + ret = StopAll(); + } + mutex.unlock(); + return ret; +} + +bool CStreamManager::StreamStatus(t_channel_id channel_id) +{ + bool ret; + mutex.lock(); + if (channel_id) + ret = (streams.find(channel_id) != streams.end()); + else + ret = !streams.empty(); + mutex.unlock(); + return ret; +} + +bool CStreamManager::Listen() +{ + struct sockaddr_in socketAddr; + int socketOptActive = 1; + int sendsize = 10*IN_SIZE; + unsigned int m = sizeof(sendsize); + + if ((listenfd = socket (AF_INET, SOCK_STREAM, 0)) < 0) { + fprintf (stderr, "network port %u open: ", port); + perror ("socket"); + return false; + } + + if (setsockopt (listenfd, SOL_SOCKET, SO_REUSEADDR, (const void *)&socketOptActive, sizeof (int)) < 0) { + fprintf (stderr, "network port %u open: error setsockopt\n", port); + perror ("setsockopt"); + goto _error; + } + + socketAddr.sin_family = AF_INET; + socketAddr.sin_port = htons (port); + socketAddr.sin_addr.s_addr = htonl (INADDR_ANY); + + if (bind (listenfd, (struct sockaddr *) &socketAddr, sizeof (socketAddr)) < 0) { + fprintf (stderr, "network port %u open: ", port); + perror ("bind"); + goto _error; + } + + if (listen (listenfd, 5) < 0) { + fprintf (stderr, "network port %u open: ", port); + perror ("listen"); + goto _error; + } + +#if 1 + setsockopt(listenfd, SOL_SOCKET, SO_SNDBUF, (void *)&sendsize, m); + sendsize = 0; + getsockopt(listenfd, SOL_SOCKET, SO_SNDBUF, (void *)&sendsize, &m); + printf("CStreamManager::Listen: on %d, fd %d (%d)\n", port, listenfd, sendsize); +#endif + return true; +_error: + close (listenfd); + return false; } -#endif \ No newline at end of file diff --git a/src/driver/streamts.h b/src/driver/streamts.h new file mode 100644 index 000000000..9b10ddeca --- /dev/null +++ b/src/driver/streamts.h @@ -0,0 +1,96 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2011-2012 CoolStream International Ltd + + License: GPLv2 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __streamts_h__ +#define __streamts_h__ + +#include +#include + +#include +#include +#include +#include + +typedef std::set stream_pids_t; +typedef std::set stream_fds_t; + +class CStreamInstance : public OpenThreads::Thread +{ + private: + bool running; + cDemux * dmx; + OpenThreads::Mutex mutex; + unsigned char * buf; + + t_channel_id channel_id; + stream_pids_t pids; + stream_fds_t fds; + + bool Send(ssize_t r); + void Close(); + void run(); + public: + CStreamInstance(int clientfd, t_channel_id chid, stream_pids_t &pids); + ~CStreamInstance(); + bool Start(); + bool Stop(); + void AddClient(int clientfd); + void RemoveClient(int clientfd); + bool HasFd(int fd); + stream_fds_t & GetFds() { return fds; } + t_channel_id GetChannelId() { return channel_id; } +}; + +typedef std::pair streammap_pair_t; +typedef std::map streammap_t; +typedef streammap_t::iterator streammap_iterator_t; + +class CStreamManager : public OpenThreads::Thread +{ + private: + bool enabled; + bool running; + int listenfd; + int port; + + OpenThreads::Mutex mutex; + static CStreamManager * sm; + + streammap_t streams; + + bool Listen(); + bool Parse(int fd, stream_pids_t &pids, t_channel_id &chid); + bool StopAll(); + void run(); + CStreamManager(); + public: + ~CStreamManager(); + static CStreamManager * getInstance(); + bool Start(int port = 0); + bool Stop(); + bool StopStream(t_channel_id channel_id = 0); + bool StreamStatus(t_channel_id channel_id = 0); + bool SetPort(int newport); + int GetPort() { return port; } +}; + +#endif From e5a2b0336cecff4068a9349a57c7a0a33d9c26a2 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 8 Nov 2012 19:13:22 +0400 Subject: [PATCH 52/64] neutrino.cpp: update for new streamts code, keep stream running in soft-standby --- src/neutrino.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 42919c114..2a3bcf6b9 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include "gui/audioplayer.h" #include "gui/bouquetlist.h" @@ -133,10 +134,6 @@ t_channel_id standby_channel_id; static pthread_t timer_thread; void * timerd_main_thread(void *data); -extern int streamts_stop; -void * streamts_main_thread(void *data); -static pthread_t stream_thread ; - void * nhttpd_main_thread(void *data); static pthread_t nhttpd_thread ; @@ -1823,7 +1820,7 @@ TIMER_START(); pthread_create (&nhttpd_thread, NULL, nhttpd_main_thread, (void *) NULL); - pthread_create (&stream_thread, NULL, streamts_main_thread, (void *) NULL); + CStreamManager::getInstance()->Start(); #ifndef DISABLE_SECTIONSD CSectionsdClient::epg_config config; @@ -3098,7 +3095,8 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) g_Radiotext->radiotext_stop(); - if(!fromDeepStandby && !CRecordManager::getInstance()->RecordingStatus()) { + bool stream_status = CStreamManager::getInstance()->StreamStatus(); + if(!fromDeepStandby && !CRecordManager::getInstance()->RecordingStatus() && !stream_status) { g_Zapit->setStandby(true); } else { g_Zapit->stopPlayBack(); @@ -3434,7 +3432,6 @@ bool CNeutrinoApp::changeNotify(const neutrino_locale_t OptionName, void * /*dat **************************************************************************************/ void stop_daemons(bool stopall) { - streamts_stop = 1; dvbsub_close(); tuxtxt_stop(); tuxtxt_close(); @@ -3447,7 +3444,7 @@ void stop_daemons(bool stopall) pthread_cancel(nhttpd_thread); pthread_join(nhttpd_thread, NULL); printf("httpd shutdown done\n"); - pthread_join(stream_thread, NULL); + CStreamManager::getInstance()->Stop(); if(stopall) { printf("timerd shutdown\n"); g_Timerd->shutdown(); From a2a6a7d5c8ff64ac9d1e06b4814457f497f064ca Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 8 Nov 2012 19:14:20 +0400 Subject: [PATCH 53/64] driver/record.cpp: stop streaming before record start --- src/driver/record.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 2d1134e54..93403f3fa 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -51,6 +51,7 @@ #include +#include #include #include #include @@ -1591,12 +1592,16 @@ bool CRecordManager::CutBackNeutrino(const t_channel_id channel_id, CFrontend * * needed, if record frontend same as live, and its on different TP */ bool found = (live_fe != frontend) || SAME_TRANSPONDER(live_channel_id, channel_id); if(found) { + /* stop stream for this channel */ + CStreamManager::getInstance()->StopStream(channel_id); ret = g_Zapit->zapTo_record(channel_id) > 0; printf("%s found same tp, zapTo_record channel_id %llx result %d\n", __FUNCTION__, channel_id, ret); } else { printf("%s mode %d last_mode %d getLastMode %d\n", __FUNCTION__, mode, last_mode, CNeutrinoApp::getInstance()->getLastMode()); StopAutoRecord(false); + /* stop all streams */ + CStreamManager::getInstance()->StopStream(); if (mode != last_mode && (last_mode != NeutrinoMessages::mode_standby || mode != CNeutrinoApp::getInstance()->getLastMode())) { CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , mode | NeutrinoMessages::norezap ); mode_changed = true; @@ -1620,6 +1625,8 @@ bool CRecordManager::CutBackNeutrino(const t_channel_id channel_id, CFrontend * g_Zapit->stopPlayBack(); if ((live_channel_id == channel_id) && g_Radiotext) g_Radiotext->radiotext_stop(); + /* in case channel_id == live_channel_id */ + CStreamManager::getInstance()->StopStream(channel_id); } if(last_mode == NeutrinoMessages::mode_standby) { //CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , NeutrinoMessages::mode_standby); From 0acc943a4f7f564bf4a9007e46b166d450946f67 Mon Sep 17 00:00:00 2001 From: satbaby Date: Thu, 8 Nov 2012 17:24:10 +0100 Subject: [PATCH 54/64] src/gui/miscsettings_menu.cpp: -add COnOffNotifier for EPG menu --- src/gui/miscsettings_menu.cpp | 48 ++++++++++++++++++++++------------- src/gui/miscsettings_menu.h | 2 +- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index 8f0d0acde..c1bd9c746 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -229,6 +229,7 @@ int CMiscMenue::showMiscSettingsMenu() delete sectionsdConfigNotifier; if(cs_get_revision() > 7) delete miscNotifier; + delete miscEpgNotifier; return res; } @@ -303,37 +304,48 @@ void CMiscMenue::showMiscSettingsMenuEpg(CMenuWidget *ms_epg) { ms_epg->addIntroItems(LOCALE_MISCSETTINGS_EPG_HEAD); - CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SAVE, &g_settings.epg_save, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); - mc->setHint("", LOCALE_MENU_HINT_EPG_SAVE); - ms_epg->addItem(mc); - CMenuOptionChooser * mc1 = new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SAVE_STANDBY, &g_settings.epg_save_standby, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); + CMenuOptionChooser * mc1 = new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SAVE_STANDBY, &g_settings.epg_save_standby, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, g_settings.epg_save); mc1->setHint("", LOCALE_MENU_HINT_EPG_SAVE_STANDBY); - ms_epg->addItem(mc1); CStringInput * miscSettings_epg_cache = new CStringInput(LOCALE_MISCSETTINGS_EPG_CACHE, &g_settings.epg_cache, 2,LOCALE_MISCSETTINGS_EPG_CACHE_HINT1, LOCALE_MISCSETTINGS_EPG_CACHE_HINT2 , "0123456789 ", sectionsdConfigNotifier); - CMenuForwarder * mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_CACHE, true, g_settings.epg_cache, miscSettings_epg_cache); + CMenuForwarder * mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_CACHE, g_settings.epg_save, g_settings.epg_cache, miscSettings_epg_cache); mf->setHint("", LOCALE_MENU_HINT_EPG_CACHE); - ms_epg->addItem(mf); CStringInput * miscSettings_epg_cache_e = new CStringInput(LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE, &g_settings.epg_extendedcache, 3,LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE_HINT1, LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE_HINT2 , "0123456789 ", sectionsdConfigNotifier); - mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE, true, g_settings.epg_extendedcache, miscSettings_epg_cache_e); - mf->setHint("", LOCALE_MENU_HINT_EPG_EXTENDEDCACHE); - ms_epg->addItem(mf); + CMenuForwarder * mf1 = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE, g_settings.epg_save, g_settings.epg_extendedcache, miscSettings_epg_cache_e); + mf1->setHint("", LOCALE_MENU_HINT_EPG_EXTENDEDCACHE); CStringInput * miscSettings_epg_old_events = new CStringInput(LOCALE_MISCSETTINGS_EPG_OLD_EVENTS, &g_settings.epg_old_events, 3,LOCALE_MISCSETTINGS_EPG_OLD_EVENTS_HINT1, LOCALE_MISCSETTINGS_EPG_OLD_EVENTS_HINT2 , "0123456789 ", sectionsdConfigNotifier); - mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_OLD_EVENTS, true, g_settings.epg_old_events, miscSettings_epg_old_events); - mf->setHint("", LOCALE_MENU_HINT_EPG_OLD_EVENTS); - ms_epg->addItem(mf); + CMenuForwarder * mf2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_OLD_EVENTS, g_settings.epg_save, g_settings.epg_old_events, miscSettings_epg_old_events); + mf2->setHint("", LOCALE_MENU_HINT_EPG_OLD_EVENTS); CStringInput * miscSettings_epg_max_events = new CStringInput(LOCALE_MISCSETTINGS_EPG_MAX_EVENTS, &g_settings.epg_max_events, 6,LOCALE_MISCSETTINGS_EPG_MAX_EVENTS_HINT1, LOCALE_MISCSETTINGS_EPG_MAX_EVENTS_HINT2 , "0123456789 ", sectionsdConfigNotifier); - mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_MAX_EVENTS, true, g_settings.epg_max_events, miscSettings_epg_max_events); - mf->setHint("", LOCALE_MENU_HINT_EPG_MAX_EVENTS); - ms_epg->addItem(mf); + CMenuForwarder * mf3 = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_MAX_EVENTS, g_settings.epg_save, g_settings.epg_max_events, miscSettings_epg_max_events); + mf3->setHint("", LOCALE_MENU_HINT_EPG_MAX_EVENTS); - mf = new CMenuForwarder(LOCALE_MISCSETTINGS_EPG_DIR, true, g_settings.epg_dir, this, "epgdir"); - mf->setHint("", LOCALE_MENU_HINT_EPG_DIR); + CMenuForwarder * mf4 = new CMenuForwarder(LOCALE_MISCSETTINGS_EPG_DIR, g_settings.epg_save, g_settings.epg_dir, this, "epgdir"); + mf4->setHint("", LOCALE_MENU_HINT_EPG_DIR); + + miscEpgNotifier = new COnOffNotifier(); + miscEpgNotifier->addItem(mc1); + miscEpgNotifier->addItem(mf); + miscEpgNotifier->addItem(mf1); + miscEpgNotifier->addItem(mf2); + miscEpgNotifier->addItem(mf3); + miscEpgNotifier->addItem(mf4); + + CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SAVE, &g_settings.epg_save, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true,miscEpgNotifier); + mc->setHint("", LOCALE_MENU_HINT_EPG_SAVE); + + ms_epg->addItem(mc); + ms_epg->addItem(mc1); ms_epg->addItem(mf); + ms_epg->addItem(mf1); + ms_epg->addItem(mf2); + ms_epg->addItem(mf3); + ms_epg->addItem(mf4); + } //filebrowser settings diff --git a/src/gui/miscsettings_menu.h b/src/gui/miscsettings_menu.h index b05d0c68a..d9c0269fb 100644 --- a/src/gui/miscsettings_menu.h +++ b/src/gui/miscsettings_menu.h @@ -41,7 +41,7 @@ class CMiscMenue : public CMenuTarget CFanControlNotifier *fanNotifier; CSectionsdConfigNotifier* sectionsdConfigNotifier; COnOffNotifier* miscNotifier; - + COnOffNotifier* miscEpgNotifier; int width; int showMiscSettingsMenu(); From 0cce4b9c80e5348967240d3ccf4303f8b4442c78 Mon Sep 17 00:00:00 2001 From: satbaby Date: Thu, 8 Nov 2012 20:08:17 +0100 Subject: [PATCH 55/64] src/system/configure_network.cpp: use old startNetwork/stop --- src/system/configure_network.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/system/configure_network.cpp b/src/system/configure_network.cpp index 6eaa20d54..ff927a375 100644 --- a/src/system/configure_network.cpp +++ b/src/system/configure_network.cpp @@ -218,11 +218,11 @@ void CNetworkConfig::commitConfig(void) void CNetworkConfig::startNetwork(void) { - const char _ifup[] = "/sbin/ifup"; + std::string cmd = "/sbin/ifup " + ifname; #ifdef DEBUG - printf("CNetworkConfig::startNetwork: %s %s\n",_ifup, ifname.c_str()); + printf("CNetworkConfig::startNetwork: %s\n", cmd.c_str()); #endif - my_system(_ifup, ifname.c_str()); + my_system("/bin/sh", "-c", cmd.c_str()); if (!inet_static) { init_vars(); @@ -232,11 +232,11 @@ void CNetworkConfig::startNetwork(void) void CNetworkConfig::stopNetwork(void) { - const char _ifdown[] = "/sbin/ifdown"; + std::string cmd = "/sbin/ifdown " + ifname; #ifdef DEBUG - printf("CNetworkConfig::stopNetwork: %s %s\n",_ifdown, ifname.c_str()); + printf("CNetworkConfig::stopNetwork: %s\n", cmd.c_str()); #endif - my_system(_ifdown, ifname.c_str()); + my_system("/bin/sh", "-c", cmd.c_str()); } From 08e66deb7519cc6e00e3041f740df40ac6bfdd7d Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 7 Nov 2012 22:13:14 +0100 Subject: [PATCH 56/64] CTextBox: remove dub allocation of m_pcFontText --- src/gui/widget/textbox.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index fb19beddb..815cdc063 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -150,7 +150,6 @@ void CTextBox::initVar(void) m_cText = ""; m_nMode = SCROLL; - m_pcFontText = NULL; m_pcFontText = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]; m_nFontTextHeight = m_pcFontText->getHeight(); m_nMaxTextWidth = 0; From 11b2242d2e58dea90d88c05bed668d5973502ec5 Mon Sep 17 00:00:00 2001 From: micha-bbg Date: Thu, 8 Nov 2012 17:12:58 +0100 Subject: [PATCH 57/64] * CTextBox: Fix displayed text width in function setText() --- src/gui/widget/textbox.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 815cdc063..47b5d0c4c 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -332,8 +332,8 @@ void CTextBox::refreshTextLineArray(void) lineBreakWidth = std::max(m_nMaxWidth, m_cFrameTextRel.iWidth - 2*text_border_width); } -// if(m_nMaxWidth) -// lineBreakWidth = m_nMaxWidth; + if(m_nMaxTextWidth) + lineBreakWidth = m_nMaxTextWidth; //TRACE("[CTextBox] line %d: lineBreakWidth %d\n", __LINE__, lineBreakWidth); @@ -595,8 +595,7 @@ bool CTextBox::setText(const std::string* newText, int max_width) { //TRACE("[CTextBox]->SetText \r\n"); bool result = false; - if (max_width>0) - m_nMaxTextWidth = max_width; + m_nMaxTextWidth = max_width; //printf("setText: _max_width %d max_width %d\n", _max_width, max_width); if (newText != NULL) From 8a89f09e6408e542d125f19ca5cfa428e571e0e3 Mon Sep 17 00:00:00 2001 From: satbaby Date: Fri, 9 Nov 2012 13:45:57 +0100 Subject: [PATCH 58/64] src/gui/zapit_setup.cpp: use COnOffNotifier --- src/gui/zapit_setup.cpp | 34 +++++++++++++--------------------- src/gui/zapit_setup.h | 4 +--- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/gui/zapit_setup.cpp b/src/gui/zapit_setup.cpp index 6a68b0704..d196e7be0 100644 --- a/src/gui/zapit_setup.cpp +++ b/src/gui/zapit_setup.cpp @@ -39,8 +39,6 @@ CZapitSetup::CZapitSetup() { - zapit1 = NULL; - zapit2 = NULL; width = w_max (40, 10); //% } @@ -67,38 +65,32 @@ void CZapitSetup::showMenu() //menue init CMenuWidget *zapit = new CMenuWidget(LOCALE_MAINMENU_SETTINGS, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_ZAPIT); zapit->addIntroItems(LOCALE_ZAPITSETUP_INFO); - + COnOffNotifier* miscZapitNotifier = new COnOffNotifier(0); //zapit - CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_ZAPITSETUP_LAST_USE, &g_settings.uselastchannel, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); + CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_ZAPITSETUP_LAST_USE, &g_settings.uselastchannel, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, miscZapitNotifier, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); mc->setHint("", LOCALE_MENU_HINT_LAST_USE); - zapit->addItem(mc); + CSelectChannelWidget select; - zapit->addItem(GenericMenuSeparatorLine); - - zapit1 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_TV , !g_settings.uselastchannel, g_settings.StartChannelTV, &select, "tv", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN ); + CMenuForwarder *zapit1 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_TV , g_settings.uselastchannel, g_settings.StartChannelTV, &select, "tv", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN ); zapit1->setHint("", LOCALE_MENU_HINT_LAST_TV); - zapit->addItem(zapit1); - zapit2 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_RADIO , !g_settings.uselastchannel, g_settings.StartChannelRadio, &select, "radio", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW ); + CMenuForwarder *zapit2 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_RADIO , g_settings.uselastchannel, g_settings.StartChannelRadio, &select, "radio", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW ); zapit2->setHint("", LOCALE_MENU_HINT_LAST_RADIO); + + miscZapitNotifier->addItem(zapit1); + miscZapitNotifier->addItem(zapit2); + + zapit->addItem(mc); + zapit->addItem(GenericMenuSeparatorLine); + zapit->addItem(zapit1); zapit->addItem(zapit2); zapit->exec(NULL, ""); + delete miscZapitNotifier; delete zapit; } -bool CZapitSetup::changeNotify(const neutrino_locale_t OptionName, void *) -{ - if (ARE_LOCALES_EQUAL(OptionName, LOCALE_ZAPITSETUP_LAST_USE)) - { - zapit1->setActive(!g_settings.uselastchannel); - zapit2->setActive(!g_settings.uselastchannel); - } - - return false; -} - //select menu CSelectChannelWidget::CSelectChannelWidget() { diff --git a/src/gui/zapit_setup.h b/src/gui/zapit_setup.h index 8e8c7f3db..95636611e 100644 --- a/src/gui/zapit_setup.h +++ b/src/gui/zapit_setup.h @@ -31,10 +31,9 @@ #include #include -class CZapitSetup : public CMenuTarget, CChangeObserver +class CZapitSetup : public CMenuTarget { private: - CMenuForwarder *zapit1, *zapit2; int width; @@ -44,7 +43,6 @@ public: CZapitSetup(); ~CZapitSetup(); int exec(CMenuTarget* parent, const std::string & actionKey); - virtual bool changeNotify(const neutrino_locale_t , void *); }; class CSelectChannelWidget : public CMenuWidget From 282560875b5b5525d8aac9c31c33e29379bdedf5 Mon Sep 17 00:00:00 2001 From: satbaby Date: Fri, 9 Nov 2012 14:50:55 +0100 Subject: [PATCH 59/64] src/neutrino.cpp:-add ask MESSAGEBOX for INACTIVITY SLEEPTIMER --- src/neutrino.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index c740fa2e5..760a5c07e 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2658,10 +2658,21 @@ _repeat: return messages_return::handled; } else if( msg == NeutrinoMessages::SLEEPTIMER) { - if(skipSleepTimer) { - printf("NeutrinoMessages::SLEEPTIMER: skiping\n"); - skipSleepTimer = false; - return messages_return::handled; + if(data) {//INACTIVITY SLEEPTIMER + skipShutdownTimer = + (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWNTIMER_ANNOUNCE, + CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes);//FIXME + if(skipShutdownTimer) { + printf("NeutrinoMessages::INACTIVITY SLEEPTIMER: skiping\n"); + skipShutdownTimer = false; + return messages_return::handled; + } + }else{ //MAIN-MENU SLEEPTIMER + if(skipSleepTimer) { + printf("NeutrinoMessages::SLEEPTIMER: skiping\n"); + skipSleepTimer = false; + return messages_return::handled; + } } if(g_settings.shutdown_real) ExitRun(true, (cs_get_revision() > 7)); From b56c86395309d984081f3916195947846dd248f0 Mon Sep 17 00:00:00 2001 From: satbaby Date: Fri, 9 Nov 2012 15:05:34 +0100 Subject: [PATCH 60/64] src/neutrino.cpp:use LOCALE_SLEEPTIMERBOX_ANNOUNCE , supplement to 282560875b5b5525d8aac9c31c33e29379bdedf5 --- src/neutrino.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 760a5c07e..72e87564d 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2660,7 +2660,7 @@ _repeat: else if( msg == NeutrinoMessages::SLEEPTIMER) { if(data) {//INACTIVITY SLEEPTIMER skipShutdownTimer = - (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWNTIMER_ANNOUNCE, + (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SLEEPTIMERBOX_ANNOUNCE, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes);//FIXME if(skipShutdownTimer) { printf("NeutrinoMessages::INACTIVITY SLEEPTIMER: skiping\n"); From fdb1fa6352e2b1841cbdd31a09e8000f14de889e Mon Sep 17 00:00:00 2001 From: satbaby Date: Fri, 9 Nov 2012 15:31:26 +0100 Subject: [PATCH 61/64] src/neutrino.cpp: see the appropriate message depending on settings --- src/neutrino.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 72e87564d..ee7849628 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2654,13 +2654,13 @@ _repeat: } else if( msg == NeutrinoMessages::ANNOUNCE_SLEEPTIMER) { if( mode != mode_scart && mode != mode_standby) - skipSleepTimer = (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SLEEPTIMERBOX_ANNOUNCE,CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); + skipSleepTimer = (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE,CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); return messages_return::handled; } else if( msg == NeutrinoMessages::SLEEPTIMER) { if(data) {//INACTIVITY SLEEPTIMER skipShutdownTimer = - (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SLEEPTIMERBOX_ANNOUNCE, + (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes);//FIXME if(skipShutdownTimer) { printf("NeutrinoMessages::INACTIVITY SLEEPTIMER: skiping\n"); From c47aebdb642c93fa01f8be8d8e65ea4aa1913f98 Mon Sep 17 00:00:00 2001 From: satbaby Date: Fri, 9 Nov 2012 17:32:15 +0100 Subject: [PATCH 62/64] src/gui/channellist.cpp:-add sort by channel number --- data/locale/deutsch.locale | 1 + data/locale/english.locale | 1 + src/gui/channellist.cpp | 22 ++++++++++++++++------ src/gui/channellist.h | 10 ++++++++++ src/neutrino.cpp | 10 ++++++---- src/system/locals.h | 1 + src/system/locals_intern.h | 1 + 7 files changed, 36 insertions(+), 10 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 817e3c5e0..9084627c8 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -211,6 +211,7 @@ channellist.foot_freq Tuning-Parameter channellist.foot_next Nachfolgesendung channellist.foot_off aus channellist.foot_sort_alpha Sortiert[alpha] +channellist.foot_sort_chnum Sortiert[nummer] channellist.foot_sort_freq Sortiert[freq] channellist.foot_sort_sat Sortiert[sat] channellist.head Alle Kanäle diff --git a/data/locale/english.locale b/data/locale/english.locale index eb24ddc23..cb537a192 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -211,6 +211,7 @@ channellist.foot_freq Sat/Freq Info channellist.foot_next next Event channellist.foot_off off channellist.foot_sort_alpha sorted[alpha] +channellist.foot_sort_chnum Sortiert[number] channellist.foot_sort_freq sorted[freq] channellist.foot_sort_sat sorted[sat] channellist.head All Services diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 92c7f50d3..eaf0a8bfb 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -223,6 +223,11 @@ void CChannelList::SortTP(void) sort(chanlist.begin(), chanlist.end(), CmpChannelByFreq()); } +void CChannelList::SortChNumber(void) +{ + sort(chanlist.begin(), chanlist.end(), CmpChannelByChNum()); +} + CZapitChannel* CChannelList::getChannel(int number) { for (uint32_t i=0; i< chanlist.size(); i++) { @@ -814,8 +819,8 @@ int CChannelList::show() int mode = CNeutrinoApp::getInstance()->GetChannelMode(); if(mode != LIST_MODE_FAV) { g_settings.channellist_sort_mode++; - if(g_settings.channellist_sort_mode > 2) - g_settings.channellist_sort_mode = 0; + if(g_settings.channellist_sort_mode > SORT_MAX-1) + g_settings.channellist_sort_mode = SORT_ALPHA; CNeutrinoApp::getInstance()->SetChannelMode(mode); paintHead(); // update button bar paint(); @@ -1631,7 +1636,7 @@ void CChannelList::paintButtonBar(bool is_current) struct button_label Button[num_buttons]; const neutrino_locale_t button_ids[] = {LOCALE_INFOVIEWER_NOW,LOCALE_INFOVIEWER_NEXT,LOCALE_MAINMENU_RECORDING,LOCALE_MAINMENU_RECORDING_STOP,NONEXISTANT_LOCALE, - LOCALE_CHANNELLIST_FOOT_SORT_ALPHA,LOCALE_CHANNELLIST_FOOT_SORT_FREQ,LOCALE_CHANNELLIST_FOOT_SORT_SAT}; + LOCALE_CHANNELLIST_FOOT_SORT_ALPHA,LOCALE_CHANNELLIST_FOOT_SORT_FREQ,LOCALE_CHANNELLIST_FOOT_SORT_SAT,LOCALE_CHANNELLIST_FOOT_SORT_CHNUM}; const std::vector buttonID_rest (button_ids, button_ids + sizeof(button_ids) / sizeof(neutrino_locale_t) ); for (int i = 0;iBouquets.size()); for (uint32_t i = 0; i < bouquetList->Bouquets.size(); i++) { - if(g_settings.channellist_sort_mode == 0) + if(g_settings.channellist_sort_mode == CChannelList::SORT_ALPHA) bouquetList->Bouquets[i]->channelList->SortAlpha(); - if(g_settings.channellist_sort_mode == 1) + if(g_settings.channellist_sort_mode == CChannelList::SORT_TP) bouquetList->Bouquets[i]->channelList->SortTP(); - if(g_settings.channellist_sort_mode == 2) + if(g_settings.channellist_sort_mode == CChannelList::SORT_SAT) bouquetList->Bouquets[i]->channelList->SortSat(); + if(g_settings.channellist_sort_mode == CChannelList::SORT_CH_NUMBER) + bouquetList->Bouquets[i]->channelList->SortChNumber(); } channelList->adjustToChannelID(channelList->getActiveChannel_ChannelID()); } diff --git a/src/system/locals.h b/src/system/locals.h index 6808a23f9..2a35ef6b2 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -238,6 +238,7 @@ typedef enum LOCALE_CHANNELLIST_FOOT_NEXT, LOCALE_CHANNELLIST_FOOT_OFF, LOCALE_CHANNELLIST_FOOT_SORT_ALPHA, + LOCALE_CHANNELLIST_FOOT_SORT_CHNUM, LOCALE_CHANNELLIST_FOOT_SORT_FREQ, LOCALE_CHANNELLIST_FOOT_SORT_SAT, LOCALE_CHANNELLIST_HEAD, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 47161f20e..905652f7f 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -238,6 +238,7 @@ const char * locale_real_names[] = "channellist.foot_next", "channellist.foot_off", "channellist.foot_sort_alpha", + "channellist.foot_sort_chnum", "channellist.foot_sort_freq", "channellist.foot_sort_sat", "channellist.head", From 9a3d2c4cba9c68bd38f3b7f40b703263e1445074 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Fri, 9 Nov 2012 18:00:01 +0100 Subject: [PATCH 63/64] - english.locale: fix german word --- data/locale/english.locale | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/locale/english.locale b/data/locale/english.locale index cb537a192..23118da8d 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -211,7 +211,7 @@ channellist.foot_freq Sat/Freq Info channellist.foot_next next Event channellist.foot_off off channellist.foot_sort_alpha sorted[alpha] -channellist.foot_sort_chnum Sortiert[number] +channellist.foot_sort_chnum sorted[number] channellist.foot_sort_freq sorted[freq] channellist.foot_sort_sat sorted[sat] channellist.head All Services From 56122fb9a09e180dfa4a6b988879f70496ad4240 Mon Sep 17 00:00:00 2001 From: satbaby Date: Sat, 10 Nov 2012 17:20:29 +0100 Subject: [PATCH 64/64] src/gui/zapit_setup.cpp: fix on/off logic --- src/gui/zapit_setup.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/zapit_setup.cpp b/src/gui/zapit_setup.cpp index d196e7be0..245af0c4e 100644 --- a/src/gui/zapit_setup.cpp +++ b/src/gui/zapit_setup.cpp @@ -65,17 +65,17 @@ void CZapitSetup::showMenu() //menue init CMenuWidget *zapit = new CMenuWidget(LOCALE_MAINMENU_SETTINGS, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_ZAPIT); zapit->addIntroItems(LOCALE_ZAPITSETUP_INFO); - COnOffNotifier* miscZapitNotifier = new COnOffNotifier(0); + COnOffNotifier* miscZapitNotifier = new COnOffNotifier(1); //zapit CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_ZAPITSETUP_LAST_USE, &g_settings.uselastchannel, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, miscZapitNotifier, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); mc->setHint("", LOCALE_MENU_HINT_LAST_USE); CSelectChannelWidget select; - CMenuForwarder *zapit1 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_TV , g_settings.uselastchannel, g_settings.StartChannelTV, &select, "tv", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN ); + CMenuForwarder *zapit1 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_TV , !g_settings.uselastchannel, g_settings.StartChannelTV, &select, "tv", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN ); zapit1->setHint("", LOCALE_MENU_HINT_LAST_TV); - CMenuForwarder *zapit2 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_RADIO , g_settings.uselastchannel, g_settings.StartChannelRadio, &select, "radio", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW ); + CMenuForwarder *zapit2 = new CMenuForwarder(LOCALE_ZAPITSETUP_LAST_RADIO , !g_settings.uselastchannel, g_settings.StartChannelRadio, &select, "radio", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW ); zapit2->setHint("", LOCALE_MENU_HINT_LAST_RADIO); miscZapitNotifier->addItem(zapit1);