From efe62f69058b539040cd775d304608f6f457a7d8 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sat, 30 Sep 2017 10:13:52 +0200 Subject: [PATCH 1/5] deutsch.locale: adjust EPGPlus.remind Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/081ac08d863a3cebf01660a79694a8c06e0281ff Author: vanhofen Date: 2017-09-30 (Sat, 30 Sep 2017) Origin message was: ------------------ - deutsch.locale: adjust EPGPlus.remind --- data/locale/deutsch.locale | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 6bf0eecb4..8523a311c 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -15,7 +15,7 @@ EPGPlus.page_up Seite vor EPGPlus.prev_bouquet Bouquet zurück EPGPlus.record Aufnahme EPGPlus.refresh_epg Aktualisieren -EPGPlus.remind Vormerken +EPGPlus.remind Umschalten EPGPlus.scroll_mode Scroll-Modus EPGPlus.stretch_mode Stretch-Modus EPGPlus.swap_mode Blättern From c4e6ecdf63a4d8274e28ab78c6d6c6bc1ef7b1aa Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Fri, 29 Sep 2017 20:37:37 +0200 Subject: [PATCH 2/5] CMenuWidget: fix "left" key for menuchoosers where the "decrement menu function" got lost by the last "simplify code and add missing break" commit. The implicit fallthrough actually was used to execute the "left" function. Reorganize the code so that it works even without the implicit fallthrough. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/ab3434e27867e2fe958d016bec0334ac60719a58 Author: Stefan Seyfried Date: 2017-09-29 (Fri, 29 Sep 2017) --- src/gui/widget/menue.cpp | 67 ++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 2a516a62a..07aaed0e6 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -928,46 +928,39 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) break; } case (CRCInput::RC_left): - { - if(hasItem() && selected > -1 && (int)items.size() > selected) { - CMenuItem* itemX = items[selected]; - if (!itemX->isMenueOptionChooser()) { - if (g_settings.menu_left_exit) - msg = CRCInput::RC_timeout; - break; - } - } - } case (CRCInput::RC_right): case (CRCInput::RC_ok): - { - if(hasItem() && selected > -1 && (int)items.size() > selected) { - //exec this item... - CMenuItem* item = items[selected]; - if (!item->isSelectable()) - break; - item->msg = msg; - fader.StopFade(); - int rv = item->exec( this ); - switch ( rv ) { - case menu_return::RETURN_EXIT_ALL: - retval = menu_return::RETURN_EXIT_ALL; - /* fall through */ - case menu_return::RETURN_EXIT: - msg = CRCInput::RC_timeout; - break; - case menu_return::RETURN_REPAINT: - case menu_return::RETURN_EXIT_REPAINT: - if (fade && washidden) - fader.StartFadeIn(); - checkHints(); - pos = selected; - paint(); - break; - } - } else + if (hasItem() && selected > -1 && (int)items.size() > selected) { + //exec this item... + CMenuItem* item = items[selected]; + if (msg == CRCInput::RC_left && g_settings.menu_left_exit && + !item->isMenueOptionChooser()) { msg = CRCInput::RC_timeout; - } + break; + } + if (!item->isSelectable()) + break; + item->msg = msg; + fader.StopFade(); + int rv = item->exec( this ); + switch ( rv ) { + case menu_return::RETURN_EXIT_ALL: + retval = menu_return::RETURN_EXIT_ALL; + /* fall through */ + case menu_return::RETURN_EXIT: + msg = CRCInput::RC_timeout; + break; + case menu_return::RETURN_REPAINT: + case menu_return::RETURN_EXIT_REPAINT: + if (fade && washidden) + fader.StartFadeIn(); + checkHints(); + pos = selected; + paint(); + break; + } + } else + msg = CRCInput::RC_timeout; break; case (CRCInput::RC_home): From ffcc69439372eb8b917aedf8dbc15129d0fa530e Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sat, 30 Sep 2017 10:13:52 +0200 Subject: [PATCH 3/5] deutsch.locale: adjust EPGPlus.remind Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/17ea8e7d638c1e9f3e23688f2b099ac86cb06057 Author: vanhofen Date: 2017-09-30 (Sat, 30 Sep 2017) Origin message was: ------------------ - deutsch.locale: adjust EPGPlus.remind --- data/locale/deutsch.locale | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index e92d0029c..3888f0dee 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -15,7 +15,7 @@ EPGPlus.page_up Seite vor EPGPlus.prev_bouquet Bouquet zurück EPGPlus.record Aufnahme EPGPlus.refresh_epg Aktualisieren -EPGPlus.remind Vormerken +EPGPlus.remind Umschalten EPGPlus.scroll_mode Scroll-Modus EPGPlus.stretch_mode Stretch-Modus EPGPlus.swap_mode Blättern From c9d4fdd9cc75d307b4b20393e4c65ed63a256f3c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 1 Oct 2017 14:12:55 +0200 Subject: [PATCH 4/5] remove "using namespace std" from header files "using namespace std" in headers is considered bad practice, so move it either into the respective cpp files or (for files which have lots of other std::xxx usage anyway) just write it out explicitly. Looking at the headers and the affected cpp files, one can actually see why it is bad practice, as it's spreading very far ;-) Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/0d9139054aebddaea9c7a3a2f225a69fcd17a868 Author: Stefan Seyfried Date: 2017-10-01 (Sun, 01 Oct 2017) --- src/driver/audiodec/basedec.cpp | 2 +- src/driver/movieinfo.cpp | 2 +- src/gui/audio_select.h | 2 -- src/gui/cam_menu.h | 2 -- src/gui/channellist.cpp | 4 ++-- src/gui/components/cc_draw.cpp | 2 +- src/gui/components/cc_item_progressbar.cpp | 2 +- src/gui/dboxinfo.cpp | 8 ++++---- src/gui/epgview.cpp | 2 +- src/gui/eventlist.cpp | 2 +- src/gui/hdd_menu.cpp | 2 +- src/gui/hdd_menu.h | 4 +--- src/gui/infoviewer.cpp | 10 +++++----- src/gui/infoviewer_bb.cpp | 4 ++-- src/gui/lua/lua_cc_window.cpp | 2 +- src/gui/moviebrowser/mb.cpp | 8 ++++---- src/gui/movieplayer.cpp | 4 ++-- src/gui/osd_setup.cpp | 2 +- src/gui/screensaver.h | 2 +- src/gui/timerlist.cpp | 6 +++--- src/gui/tmdb.cpp | 2 +- src/gui/update.cpp | 2 +- src/gui/update_ext.cpp | 4 ++-- src/gui/upnpbrowser.cpp | 2 +- src/gui/widget/mountchooser.cpp | 4 ++-- src/gui/widget/msgbox.cpp | 2 ++ src/gui/widget/shellwindow.cpp | 4 ++-- src/gui/widget/stringinput.cpp | 2 +- src/nhttpd/tuxboxapi/controlapi.cpp | 2 +- src/nhttpd/tuxboxapi/neutrinoapi.cpp | 2 +- src/nhttpd/tuxboxapi/neutrinoyparser.cpp | 2 +- src/system/helpers-json.h | 6 ++---- src/system/ytparser.cpp | 4 ++-- src/zapit/include/zapit/bouquets.h | 10 ++++------ src/zapit/include/zapit/getservices.h | 2 +- src/zapit/src/bouquets.cpp | 2 +- src/zapit/src/getservices.cpp | 4 ++-- 37 files changed, 60 insertions(+), 68 deletions(-) diff --git a/src/driver/audiodec/basedec.cpp b/src/driver/audiodec/basedec.cpp index 34d8cbeb9..f5a35e0b1 100644 --- a/src/driver/audiodec/basedec.cpp +++ b/src/driver/audiodec/basedec.cpp @@ -72,7 +72,7 @@ CBaseDec::RetCode CBaseDec::DecoderBase(CAudiofile* const in, RetCode Status = OK; FILE* fp; - if(( in->FileType == CFile::STREAM_AUDIO ) && (in->Filename.find(".flv") != string::npos)) + if ((in->FileType == CFile::STREAM_AUDIO) && (in->Filename.find(".flv") != std::string::npos)) { fp = fopen( in->Filename.c_str(), "rc" ); } diff --git a/src/driver/movieinfo.cpp b/src/driver/movieinfo.cpp index 0714c0a05..415ef9374 100644 --- a/src/driver/movieinfo.cpp +++ b/src/driver/movieinfo.cpp @@ -55,7 +55,7 @@ CMovieInfo::~CMovieInfo() bool CMovieInfo::convertTs2XmlName(std::string& filename) { size_t lastdot = filename.find_last_of("."); - if (lastdot != string::npos) { + if (lastdot != std::string::npos) { filename.erase(lastdot + 1); filename.append("xml"); return true; diff --git a/src/gui/audio_select.h b/src/gui/audio_select.h index 0dc27572f..b1177ccbf 100644 --- a/src/gui/audio_select.h +++ b/src/gui/audio_select.h @@ -32,8 +32,6 @@ -using namespace std; - class CAudioSelectMenuHandler : public CMenuTarget { private: diff --git a/src/gui/cam_menu.h b/src/gui/cam_menu.h index 829aa3433..9797f5c4a 100644 --- a/src/gui/cam_menu.h +++ b/src/gui/cam_menu.h @@ -29,8 +29,6 @@ #include -using namespace std; - class CCAMMenuHandler : public CMenuTarget, public CChangeObserver { private: diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 2d25fbcff..efe84b35b 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -1693,7 +1693,7 @@ void CChannelList::showChannelLogo() header->getChannelLogoObject()->paint(); } else - header->setChannelLogo(0, string()); + header->setChannelLogo(0, std::string()); } #define NUM_LIST_BUTTONS_SORT 9 @@ -2131,7 +2131,7 @@ void CChannelList::paintHead() if (bouquet && bouquet->zapitBouquet && bouquet->zapitBouquet->bLocked != g_settings.parentallock_defaultlocked) header->setIcon(NEUTRINO_ICON_LOCK); - string header_txt = !edit_state ? name : string(g_Locale->getText(LOCALE_CHANNELLIST_EDIT)) + ": " + name; + std::string header_txt = !edit_state ? name : std::string(g_Locale->getText(LOCALE_CHANNELLIST_EDIT)) + ": " + name; fb_pixel_t header_txt_col = (edit_state ? COL_RED : COL_MENUHEAD_TEXT); header->setColorBody(COL_MENUHEAD_PLUS_0); diff --git a/src/gui/components/cc_draw.cpp b/src/gui/components/cc_draw.cpp index 0ac6128c0..e086ac503 100644 --- a/src/gui/components/cc_draw.cpp +++ b/src/gui/components/cc_draw.cpp @@ -45,7 +45,7 @@ CCDraw::CCDraw() : COSDFader(g_settings.theme.menu_Content_alpha) col_frame = col_frame_old = COL_FRAME_PLUS_0; col_shadow_clean = 0; - cc_body_image = cc_body_image_old = string(); + cc_body_image = cc_body_image_old = std::string(); fr_thickness = fr_thickness_old = 0; diff --git a/src/gui/components/cc_item_progressbar.cpp b/src/gui/components/cc_item_progressbar.cpp index 5a639c825..1a069a1dc 100644 --- a/src/gui/components/cc_item_progressbar.cpp +++ b/src/gui/components/cc_item_progressbar.cpp @@ -107,7 +107,7 @@ void CProgressBar::initDimensions() pb_y = (cc_parent ? cc_yr : y) + fr_thickness; // width for active bar with current value - pb_active_width = max(0, pb_last_width); + pb_active_width = std::max(0, pb_last_width); if (pb_max_value) pb_active_width = (width - 2*fr_thickness) * pb_value / pb_max_value; diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 78f8c80ea..66e52ecbe 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -288,10 +288,10 @@ void CDBoxInfoWidget::paint() while (getline(in, line)) { size_t firstslash = line.find_first_of('/'); size_t firstspace = line.find_first_of(' '); - if ( (firstspace != string::npos && firstslash != string::npos && firstslash < firstspace) || (line.find("rootfs") == 0) ) { + if ( (firstspace != std::string::npos && firstslash != std::string::npos && firstslash < firstspace) || (line.find("rootfs") == 0) ) { firstspace++; size_t nextspace = line.find_first_of(' ', firstspace); - if (nextspace == string::npos || line.find("nodev", nextspace + 1) != string::npos) + if (nextspace == std::string::npos || line.find("nodev", nextspace + 1) != std::string::npos) continue; std::string mountpoint = line.substr(firstspace, nextspace - firstspace); struct stat st; @@ -344,7 +344,7 @@ void CDBoxInfoWidget::paint() std::string line; while (getline(in, line)) { size_t colon = line.find_first_of(':'); - if (colon != string::npos && colon > 1) { + if (colon != std::string::npos && colon > 1) { std::string key = line.substr(0, colon - 1); std::string val = line.substr(colon + 1); cpuinfo[trim(key)] = trim(val); @@ -363,7 +363,7 @@ void CDBoxInfoWidget::paint() sprintf(ss, "%016llx", cs_get_serial()); title += ", S/N "; title += ss; - width = max(width, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(title, true) + 50); + width = std::max(width, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(title, true) + 50); x = getScreenStartX(width); if (!header) diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 240f0087a..72dfb73fe 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -300,7 +300,7 @@ void CEpgData::showText(int startPos, int ypos, bool has_cover, bool fullClear) 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 ){ + while( pos2 != std::string::npos || pos1 != std::string::npos ){ switch(count){ case 1: offset += max_wday_w; diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 97d9a5bc4..e86c77288 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -363,7 +363,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna COSDFader fader(g_settings.theme.menu_Content_alpha); fader.StartFadeIn(); if(!followlist.empty()){ - insert_iterator >ii(evtlist,evtlist.begin()); + std::insert_iterator >ii(evtlist,evtlist.begin()); copy(followlist.begin(), followlist.end(), ii); showfollow = true; }else{ diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index fba3e6ef0..0bb0fd86b 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -366,7 +366,7 @@ void CHDDMenuHandler::setRecordPath(std::string &dev) return; } /* don't annoy if the recordingdir is a symlink pointing to the 'right' location */ - string readl = backtick("readlink -f " + g_settings.network_nfs_recordingdir); + std::string readl = backtick("readlink -f " + g_settings.network_nfs_recordingdir); readl = trim(readl); if (newpath.compare(readl) == 0) { printf("CHDDMenuHandler::%s: recordingdir is a symlink to %s\n", diff --git a/src/gui/hdd_menu.h b/src/gui/hdd_menu.h index 13a320e62..6a56fd836 100644 --- a/src/gui/hdd_menu.h +++ b/src/gui/hdd_menu.h @@ -28,8 +28,6 @@ #include "widget/menue.h" #include -using namespace std; - struct devtool_s { std::string fmt; std::string fsck; @@ -64,7 +62,7 @@ class CHDDMenuHandler : public CMenuTarget bool mounted; }; std::vector hdd_list; - struct cmp_hdd_by_name: public binary_function + struct cmp_hdd_by_name: public std::binary_function { bool operator() (const struct hdd_s &c1, const struct hdd_s &c2) { diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index 0420e50dd..a42e3612d 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -200,11 +200,11 @@ void CInfoViewer::start () 2 * g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]->getHeight() + 25; infoViewerBB->Init(); - ChanWidth = max(125, 4 * g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER]->getMaxDigitWidth() + 10); + ChanWidth = std::max(125, 4 * g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER]->getMaxDigitWidth() + 10); ChanHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER]->getHeight()/* * 9/8*/; ChanHeight += g_SignalFont->getHeight()/2; - ChanHeight = max(75, ChanHeight); + ChanHeight = std::max(75, ChanHeight); numbox_offset = 3; BoxStartX = g_settings.screen_StartX + 10; @@ -216,7 +216,7 @@ void CInfoViewer::start () ChanInfoX = BoxStartX + (ChanWidth / 3); initClock(); - time_height = max(ChanHeight / 2, clock->getHeight()); + time_height = std::max(ChanHeight / 2, clock->getHeight()); time_width = clock->getWidth(); } @@ -2115,8 +2115,8 @@ void CInfoViewer::showInfoFile() } //get text from file and set it to info object, exit and delete object if failed - string old_txt = infobar_txt->getText(); - string new_txt = infobar_txt->getTextFromFile(infobar_file); + std::string old_txt = infobar_txt->getText(); + std::string new_txt = infobar_txt->getTextFromFile(infobar_file); bool has_text = infobar_txt->setText(new_txt, CTextBox::CENTER, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]); if (new_txt.empty()){ killInfobarText(); diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index 0a0091a3b..3dcc38ec3 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -738,7 +738,7 @@ void CInfoViewerBB::paint_ca_icons(int caid, const char *icon, int &icon_space_o int endx = g_InfoViewer->BoxEndX - (g_settings.infobar_casystem_frame ? 20 : 10); int py = g_InfoViewer->BoxEndY + (g_settings.infobar_casystem_frame ? 4 : 2); /* hand-crafted, should be automatic */ int px = 0; - static map > icon_map; + static std::map > icon_map; const int icon_space = 10, icon_number = 10; static int icon_offset[icon_number] = {0,0,0,0,0,0,0,0,0,0}; @@ -748,7 +748,7 @@ void CInfoViewerBB::paint_ca_icons(int caid, const char *icon, int &icon_space_o if (!init_flag) { init_flag = true; int icon_sizeH = 0, index = 0; - map >::const_iterator it; + std::map >::const_iterator it; icon_map[0x0E00] = std::make_pair(index++,"powervu"); icon_map[0x4A00] = std::make_pair(index++,"d"); diff --git a/src/gui/lua/lua_cc_window.cpp b/src/gui/lua/lua_cc_window.cpp index 0d4c9d412..bec918eef 100644 --- a/src/gui/lua/lua_cc_window.cpp +++ b/src/gui/lua/lua_cc_window.cpp @@ -140,7 +140,7 @@ int CLuaInstCCWindow::CCWindowNew(lua_State *L) else { CComponentsFooter* footer = (*udata)->w->getFooterObject(); if (footer) { - vector buttons; + std::vector buttons; if (!btnRed.empty()) { button_label_cc btnSred; btnSred.button = NEUTRINO_ICON_BUTTON_RED; diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index cd9200b3b..77b9f0976 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -1279,10 +1279,10 @@ std::string CMovieBrowser::getScreenshotName(std::string movie, bool is_dir) else found = movie.find_last_of("."); - if (found == string::npos) + if (found == std::string::npos) return ""; - vector::iterator it = PicExts.begin(); + std::vector::iterator it = PicExts.begin(); while (it < PicExts.end()) { ret = movie; ext = *it; @@ -1325,7 +1325,7 @@ void CMovieBrowser::refreshChannelLogo(void) if (m_channelLogo && m_channelLogo->hasLogo()) { // TODO: move into an own handler, eg. header, so channel logo should be paint in header object - m_channelLogo->setWidth(min(m_channelLogo->getWidth(), w_logo_max), true); + m_channelLogo->setWidth(std::min(m_channelLogo->getWidth(), w_logo_max), true); if (m_channelLogo->getHeight() > h_logo_max) m_channelLogo->setHeight(h_logo_max, true); @@ -2846,7 +2846,7 @@ bool CMovieBrowser::addFile(CFile &file, int dirItNr) movieInfo.file = file; if(!m_movieInfo.loadMovieInfo(&movieInfo)) { - movieInfo.channelName = string(g_Locale->getText(LOCALE_MOVIEPLAYER_HEAD)); + movieInfo.channelName = std::string(g_Locale->getText(LOCALE_MOVIEPLAYER_HEAD)); movieInfo.epgTitle = file.getFileName(); } movieInfo.dirItNr = dirItNr; diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index ab5b69b3f..70fc90d4b 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -815,7 +815,7 @@ bool CMoviePlayerGui::luaGetUrl(const std::string &script, const std::string &fi return false; } - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool ok = parseJsonFromString(result_string, &root, &errMsg); if (!ok) { @@ -2586,7 +2586,7 @@ void CMoviePlayerGui::showSubtitle(neutrino_msg_data_t data) size_t start = 0, end = 0; /* split string with \N as newline */ std::string delim("\\N"); - while ((end = str.find(delim, start)) != string::npos) { + while ((end = str.find(delim, start)) != std::string::npos) { subtext.push_back(str.substr(start, end - start)); start = end + 2; } diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index b3821636f..c1ed05dfc 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -1308,7 +1308,7 @@ void COsdSetup::showOsdVolumeSetup(CMenuWidget *menu_volume) // volume size int vMin = CVolumeHelper::getInstance()->getVolIconHeight(); - g_settings.volume_size = max(g_settings.volume_size, vMin); + g_settings.volume_size = std::max(g_settings.volume_size, vMin); CMenuOptionNumberChooser * nc = new CMenuOptionNumberChooser(LOCALE_EXTRA_VOLUME_SIZE, &g_settings.volume_size, true, vMin, 50); nc->setHint("", LOCALE_MENU_HINT_VOLUME_SIZE); menu_volume->addItem(nc); diff --git a/src/gui/screensaver.h b/src/gui/screensaver.h index 0a9605561..9dff31919 100644 --- a/src/gui/screensaver.h +++ b/src/gui/screensaver.h @@ -39,7 +39,7 @@ class CScreenSaver : public sigc::trackable CComponentsFrmClock *scr_clock; pthread_t thrScreenSaver; static void* ScreenSaverPrg(void *arg); - vector v_bg_files; + std::vector v_bg_files; unsigned int index; t_channel_id pip_channel_id; bool status_mute; diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index f217679a1..30abd3eda 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -739,7 +739,7 @@ bool CTimerList::RemoteBoxChanExists(t_channel_id channel_id) r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout); - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool ok = parseJsonFromString(r_url, &root, &errMsg); if (!ok) { @@ -796,7 +796,7 @@ void CTimerList::RemoteBoxTimerList(CTimerd::TimerList &rtimerlist) r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout); //printf("[remotetimer] timers:%s\n",r_url.c_str()); - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool ok = parseJsonFromString(r_url, &root, &errMsg); if (!ok) { @@ -1285,7 +1285,7 @@ void CTimerList::paintItem(int pos) r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timer.channel_id); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout); - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool ok = parseJsonFromString(r_url, &root, &errMsg); if (!ok) { diff --git a/src/gui/tmdb.cpp b/src/gui/tmdb.cpp index 5a8208e27..b4aff486d 100644 --- a/src/gui/tmdb.cpp +++ b/src/gui/tmdb.cpp @@ -198,7 +198,7 @@ bool cTmdb::GetMovieDetails(std::string lang) if (!getUrl(url, answer)) return false; - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool ok = parseJsonFromString(answer, &root, &errMsg); if (!ok) { diff --git a/src/gui/update.cpp b/src/gui/update.cpp index e0ce4cf0a..40e1a2312 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -411,7 +411,7 @@ bool CFlashUpdate::checkVersion4Update() if (allow_flash) UpdatesFilter.addFilter(FILEBROWSER_UPDATE_FILTER); - string filters[] = {"bin", "txt", "opk", "ipk"}; + std::string filters[] = {"bin", "txt", "opk", "ipk"}; for(size_t i=0; i::iterator it = blackList.begin(); it != blackList.end(); ++it) { + for(std::vector::iterator it = blackList.begin(); it != blackList.end(); ++it) { if (*it == file) { DBG_MSG("BlacklistEntry %s\n", (*it).c_str()); WRITE_UPDATE_LOG("BlacklistEntry: %s\n", (*it).c_str()); @@ -559,7 +559,7 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) { char buf[PATH_MAX]; static struct stat FileInfo; - vector::iterator it; + std::vector::iterator it; f1 = fopen(backupList.c_str(), "r"); if (f1 == NULL) { diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index 1f4c67b17..2b335df76 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -1197,7 +1197,7 @@ void CUpnpBrowserGui::paintDetails(UPnPEntry *entry, bool use_playing) timebox.kill(); m_playing_entry_is_shown = false; }else{ - string text = ""; + std::string text = ""; if (use_playing){ if (!m_playing_entry_is_shown){ m_playing_entry_is_shown = true; diff --git a/src/gui/widget/mountchooser.cpp b/src/gui/widget/mountchooser.cpp index fa56e462f..b21f8f672 100644 --- a/src/gui/widget/mountchooser.cpp +++ b/src/gui/widget/mountchooser.cpp @@ -48,8 +48,8 @@ CMountChooser::CMountChooser(const neutrino_locale_t Name, const std::string & I for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++) { if (!g_settings.network_nfs[i].local_dir.empty() && - (g_settings.network_nfs[i].mount_options1.find("rw") != string::npos || - g_settings.network_nfs[i].mount_options2.find("rw") != string::npos)) + (g_settings.network_nfs[i].mount_options1.find("rw") != std::string::npos || + g_settings.network_nfs[i].mount_options2.find("rw") != std::string::npos)) { std::string s = g_settings.network_nfs[i].local_dir + " (" + g_settings.network_nfs[i].ip + ":" + g_settings.network_nfs[i].dir + ")"; snprintf(indexStr,sizeof(indexStr),"%d",i); diff --git a/src/gui/widget/msgbox.cpp b/src/gui/widget/msgbox.cpp index 79fa64e93..11aefe2f4 100644 --- a/src/gui/widget/msgbox.cpp +++ b/src/gui/widget/msgbox.cpp @@ -41,6 +41,8 @@ #define MIN_WINDOW_WIDTH (MAX_WINDOW_WIDTH>>1) #define MIN_WINDOW_HEIGHT 40 +using namespace std; /* TODO: remove all std:: prefixes in this file */ + CMsgBox::CMsgBox( const char* Text, const char* Title, const char* Icon, diff --git a/src/gui/widget/shellwindow.cpp b/src/gui/widget/shellwindow.cpp index 60af07803..2e67e1e8d 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -83,7 +83,7 @@ static int read_line(int fd, struct pollfd *fds, char *b, size_t sz) return i; } -static std::string lines2txt(list &lines) +static std::string lines2txt(std::list &lines) { std::string txt = ""; for (std::list::const_iterator it = lines.begin(), end = lines.end(); it != end; ++it) { @@ -122,7 +122,7 @@ void CShellWindow::exec() int h_shell = frameBuffer->getScreenHeight(); int w_shell = frameBuffer->getScreenWidth(); unsigned int lines_max = h_shell / font->getHeight(); - list lines; + std::list lines; CBox textBoxPosition(frameBuffer->getScreenX(), frameBuffer->getScreenY(), w_shell, h_shell); if (textBox == NULL){ textBox = new CTextBox(cmd.c_str(), font, CTextBox::BOTTOM, &textBoxPosition); diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index b4b8a30c8..9ae14319e 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -490,7 +490,7 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) } else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { - string tmp_name = name == NONEXISTANT_LOCALE ? head : g_Locale->getText(name); + std::string tmp_name = name == NONEXISTANT_LOCALE ? head : g_Locale->getText(name); if ((trim (*valueString) != trim(oldval)) && (ShowMsg(tmp_name, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbCancel) == CMsgBox::mbrCancel)) { timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]); diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index 847bdada0..90dbad0b4 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -1068,7 +1068,7 @@ void CControlAPI::LogolistCGI(CyhookHandler *hh) if (g_PicViewer->GetLogoName(channel->getChannelID(), NeutrinoAPI->GetServiceName(channel->getChannelID()), logo_used, NULL, NULL)) { realpath(logo_used.c_str(), _real); - logo_real = string(_real); + logo_real = std::string(_real); if (strcmp(logo_used.c_str(), logo_real.c_str()) == 0) logo_real.clear(); } diff --git a/src/nhttpd/tuxboxapi/neutrinoapi.cpp b/src/nhttpd/tuxboxapi/neutrinoapi.cpp index 6bd31953c..6aef17954 100644 --- a/src/nhttpd/tuxboxapi/neutrinoapi.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoapi.cpp @@ -514,7 +514,7 @@ std::string CNeutrinoAPI::getCryptInfoAsString(void) for(casys_map_iterator_t it = channel->camap.begin(); it != channel->camap.end(); ++it) { int caid = (*it) & 0xFF00; if(caid == caids[i]) - out << casys[i] << hex << (*it) << "\n"; + out << casys[i] << std::hex << (*it) << "\n"; } } diff --git a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp index 2dd411c59..5ad95bac3 100644 --- a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp @@ -585,7 +585,7 @@ std::string CNeutrinoYParser::func_get_logo_name(CyhookHandler *hh, std::string std::string fileType[] = { ".png", ".jpg" , ".gif" }; std::string channelIdShort = channelId.substr(channelId.length() - 12); - channelIdShort = channelIdShort.erase(0, min(channelIdShort.find_first_not_of('0'), channelIdShort.size()-1)); + channelIdShort = channelIdShort.erase(0, std::min(channelIdShort.find_first_not_of('0'), channelIdShort.size()-1)); std::string channelName = ""; t_channel_id chId = 0; diff --git a/src/system/helpers-json.h b/src/system/helpers-json.h index 0e4923649..23582d431 100644 --- a/src/system/helpers-json.h +++ b/src/system/helpers-json.h @@ -23,9 +23,7 @@ #include -using namespace std; - -bool parseJsonFromFile(string& jFile, Json::Value *root, string *errMsg); -bool parseJsonFromString(string& jData, Json::Value *root, string *errMsg); +bool parseJsonFromFile(std::string& jFile, Json::Value *root, std::string *errMsg); +bool parseJsonFromString(std::string& jData, Json::Value *root, std::string *errMsg); #endif diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp index a2762f279..e42f7e032 100644 --- a/src/system/ytparser.cpp +++ b/src/system/ytparser.cpp @@ -289,7 +289,7 @@ std::string cYTFeedParser::getXmlData(xmlNodePtr node) bool cYTFeedParser::parseFeedJSON(std::string &answer) { - string errMsg = ""; + std::string errMsg = ""; Json::Value root; std::ostringstream ss; @@ -384,7 +384,7 @@ bool cYTFeedParser::parseFeedDetailsJSON(cYTVideoInfo* vinfo) if (!getUrl(url, answer)) return false; - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool parsedSuccess = parseJsonFromString(answer, &root, &errMsg); if (!parsedSuccess) { diff --git a/src/zapit/include/zapit/bouquets.h b/src/zapit/include/zapit/bouquets.h index 6c885a562..2adc88f4b 100644 --- a/src/zapit/include/zapit/bouquets.h +++ b/src/zapit/include/zapit/bouquets.h @@ -18,12 +18,10 @@ #include "channel.h" -using namespace std; - -typedef map tallchans; +typedef std::map tallchans; typedef tallchans::iterator tallchans_iterator; -typedef vector ZapitChannelList; +typedef std::vector ZapitChannelList; typedef ZapitChannelList::iterator zapit_list_it_t; #define DEFAULT_BQ_ID 0 @@ -83,7 +81,7 @@ class CZapitBouquet bool getChannels(ZapitChannelList &list, bool tv, int flags = CZapitChannel::PRESENT); }; -typedef vector BouquetList; +typedef std::vector BouquetList; class CBouquetManager { @@ -168,7 +166,7 @@ class CBouquetManager * For instance all countless variants of the letter a have to be regarded as the same letter. */ -struct CmpBouquetByChName: public binary_function +struct CmpBouquetByChName: public std::binary_function { static bool comparetolower(const char a, const char b) { diff --git a/src/zapit/include/zapit/getservices.h b/src/zapit/include/zapit/getservices.h index 780b525c0..f82908e26 100644 --- a/src/zapit/include/zapit/getservices.h +++ b/src/zapit/include/zapit/getservices.h @@ -40,7 +40,7 @@ extern transponder_list_t transponders; typedef std::map sat_transponder_map_t; -typedef map channel_map_t; +typedef std::map channel_map_t; typedef channel_map_t::iterator channel_map_iterator_t; typedef std::pair channel_pair_t; typedef std::pair channel_insert_res_t; diff --git a/src/zapit/src/bouquets.cpp b/src/zapit/src/bouquets.cpp index 271751cd0..ff018ded9 100644 --- a/src/zapit/src/bouquets.cpp +++ b/src/zapit/src/bouquets.cpp @@ -542,7 +542,7 @@ void CBouquetManager::makeRemainingChannelsBouquet(void) int j = CServiceManager::getInstance()->GetMaxNumber(true); /* FIXME temp debug */ printf("############## CBouquetManager::makeRemainingChannelsBouquet: numbers start at: tv %d radio %d ############\n", i, j); - for (vector::const_iterator it = Bouquets.begin(); it != Bouquets.end(); ++it) { + for (std::vector::const_iterator it = Bouquets.begin(); it != Bouquets.end(); ++it) { renumChannels((*it)->tvChannels, i, (*it)->bUser ? NULL : (char *) (*it)->Name.c_str()); renumChannels((*it)->radioChannels, j, (*it)->bUser ? NULL : (char *) (*it)->Name.c_str()); } diff --git a/src/zapit/src/getservices.cpp b/src/zapit/src/getservices.cpp index 5bb5d24aa..a9d331803 100644 --- a/src/zapit/src/getservices.cpp +++ b/src/zapit/src/getservices.cpp @@ -418,7 +418,7 @@ void CServiceManager::ParseTransponders(xmlNodePtr node, t_satellite_position sa transponder_id_t tid = CREATE_TRANSPONDER_ID64(freq, satellitePosition,original_network_id,transport_stream_id); transponder t(tid, feparams); - pair::iterator,bool> ret; + std::pair::iterator,bool> ret; ret = transponders.insert(transponder_pair_t(tid, t)); if (ret.second == false) t.dump("[zapit] duplicate in all transponders:"); @@ -1379,7 +1379,7 @@ bool CServiceManager::GetTransponder(transponder_id_t tid, transponder &t) void CServiceManager::UpdateSatTransponders(t_satellite_position satellitePosition) { - pair::iterator,bool> ret; + std::pair::iterator,bool> ret; transponder_list_t & stransponders = satelliteTransponders[satellitePosition]; for (transponder_list_t::iterator tI = transponders.begin(); tI != transponders.end(); ++tI) { for (stiterator stI = stransponders.begin(); stI != stransponders.end(); ++stI) { From 80df05e950c371eee930ca7c466b169bcbcfa2e2 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 1 Oct 2017 14:38:52 +0200 Subject: [PATCH 5/5] helpers/readFile: limit memory allocations Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/2f39081708e362454e91973a93b9d43991274562 Author: Stefan Seyfried Date: 2017-10-01 (Sun, 01 Oct 2017) --- src/system/helpers.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index d47485a62..246af293a 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -1455,8 +1455,16 @@ string readFile(string file) if (tmpData.is_open()) { tmpData.seekg(0, tmpData.end); int length = tmpData.tellg(); + if (length > 0xffff) { /* longer than 64k? better read in chunks! */ + cerr << __func__ << ": file " << file << " too big (" << length << " bytes)" << endl; + return ""; + } tmpData.seekg(0, tmpData.beg); char* buffer = new char[length+1]; + if (! buffer) { + cerr << __func__ << ": allocating " << (length + 1) << " bytes for buffer failed" << endl; + return ""; + } tmpData.read(buffer, length); tmpData.close(); buffer[length] = '\0';