From ec132fe91bd1f05e0c56f30f174585991771124c Mon Sep 17 00:00:00 2001 From: TangoCash Date: Sun, 20 Nov 2016 19:24:08 +0100 Subject: [PATCH 01/12] add option to read saved epg data frequently Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/6cd5dd8e23f55954070f22c719417d9755dd4f91 Author: TangoCash Date: 2016-11-20 (Sun, 20 Nov 2016) --- data/locale/deutsch.locale | 1 + data/locale/english.locale | 1 + lib/sectionsdclient/sectionsdMsg.h | 1 + lib/sectionsdclient/sectionsdclient.cpp | 1 + lib/sectionsdclient/sectionsdclient.h | 1 + src/eitd/sectionsd.cpp | 24 ++++++++++++++++++-- src/gui/miscsettings_menu.cpp | 30 +++++++++++++++++++++++-- src/gui/miscsettings_menu.h | 1 + src/neutrino.cpp | 6 ++++- src/system/locals.h | 2 ++ src/system/locals_intern.h | 2 ++ src/system/settings.h | 1 + 12 files changed, 66 insertions(+), 5 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index c84063a86..71f8d8023 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1514,6 +1514,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_read Gespeicherte EPG-Daten einlesen +miscsettings.epg_read_frequently EPG regelmäßig einlesen miscsettings.epg_save EPG zwischenspeichern miscsettings.epg_save_frequently EPG regelmäßig speichern miscsettings.epg_save_mode Nur Favoriten diff --git a/data/locale/english.locale b/data/locale/english.locale index b6b6e62f1..4b1e7e87b 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1514,6 +1514,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_read Restore EPG on boot +miscsettings.epg_read_frequently Restore EPG frequently miscsettings.epg_save Save EPG on shutdown miscsettings.epg_save_frequently Save EPG frequently miscsettings.epg_save_mode Favorites only diff --git a/lib/sectionsdclient/sectionsdMsg.h b/lib/sectionsdclient/sectionsdMsg.h index 9b6b666a4..440feabae 100644 --- a/lib/sectionsdclient/sectionsdMsg.h +++ b/lib/sectionsdclient/sectionsdMsg.h @@ -102,6 +102,7 @@ struct sectionsd // std::string network_ntpserver; // std::string epg_dir; int epg_save_frequently; + int epg_read_frequently; }; }; diff --git a/lib/sectionsdclient/sectionsdclient.cpp b/lib/sectionsdclient/sectionsdclient.cpp index e4dcee4e5..c6be1fac2 100644 --- a/lib/sectionsdclient/sectionsdclient.cpp +++ b/lib/sectionsdclient/sectionsdclient.cpp @@ -207,6 +207,7 @@ void CSectionsdClient::setConfig(const epg_config config) msg->network_ntpenable = config.network_ntpenable; msg->epg_extendedcache = config.epg_extendedcache; msg->epg_save_frequently= config.epg_save_frequently; + msg->epg_read_frequently= config.epg_read_frequently; // config.network_ntpserver: strcpy(&pData[sizeof(sectionsd::commandSetConfig)], config.network_ntpserver.c_str()); // config.epg_dir: diff --git a/lib/sectionsdclient/sectionsdclient.h b/lib/sectionsdclient/sectionsdclient.h index 1f70b01f2..c827d83b5 100644 --- a/lib/sectionsdclient/sectionsdclient.h +++ b/lib/sectionsdclient/sectionsdclient.h @@ -163,6 +163,7 @@ class CSectionsdClient : private CBasicClient int epg_extendedcache; std::string network_ntpserver; int epg_save_frequently; + int epg_read_frequently; std::string epg_dir; } epg_config; diff --git a/src/eitd/sectionsd.cpp b/src/eitd/sectionsd.cpp index 91e6b0dfa..e131b423d 100644 --- a/src/eitd/sectionsd.cpp +++ b/src/eitd/sectionsd.cpp @@ -72,7 +72,7 @@ static bool notify_complete = false; /* period to clean cached sections and force restart sections read */ #define META_HOUSEKEEPING_COUNT (24 * 60 * 60) / HOUSEKEEPING_SLEEP // meta housekeeping after XX housekeepings - every 24h - #define STANDBY_HOUSEKEEPING_COUNT (60 * 60) / HOUSEKEEPING_SLEEP -#define EPG_SAVE_FREQUENTLY_COUNT (60 * 60) / HOUSEKEEPING_SLEEP +#define EPG_SERVICE_FREQUENTLY_COUNT (60 * 60) / HOUSEKEEPING_SLEEP // Timeout bei tcp/ip connections in ms #define READ_TIMEOUT_IN_SECONDS 2 @@ -85,6 +85,7 @@ static bool notify_complete = false; #define TIMEOUTS_EIT_VERSION_WAIT (2 * CHECK_RESTART_DMX_AFTER_TIMEOUTS) static unsigned int epg_save_frequently; +static unsigned int epg_read_frequently; static long secondsToCache; long int secondsExtendedTextCache = 0; static long oldEventsAre; @@ -1126,6 +1127,8 @@ static void commandSetConfig(int connfd, char *data, const unsigned /*dataLength secondsExtendedTextCache = (long)(pmsg->epg_extendedcache)*60L*60L; max_events = pmsg->epg_max_events; epg_save_frequently = pmsg->epg_save_frequently; + epg_read_frequently = pmsg->epg_read_frequently; + unlockEvents(); bool time_wakeup = false; @@ -2093,7 +2096,7 @@ static void *houseKeepingThread(void *) removeOldEvents(oldEventsAre); // alte Events ecount++; - if (ecount == EPG_SAVE_FREQUENTLY_COUNT) + if (ecount == EPG_SERVICE_FREQUENTLY_COUNT) { if (epg_save_frequently > 0) { @@ -2106,6 +2109,22 @@ static void *houseKeepingThread(void *) } writeEventsToFile(d.c_str()); } + if (epg_read_frequently > 0) + { + pthread_t thrInsert; + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + std::string d = epg_dir + "/"; + + printf("[%s]: %s\n",__func__,d.c_str()); + + if (pthread_create (&thrInsert, &attr, insertEventsfromFile, (void *)d.c_str() )) + { + perror("sectionsd: pthread_create()"); + } + pthread_attr_destroy(&attr); + } ecount = 0; } @@ -2163,6 +2182,7 @@ bool CEitManager::Start() oldEventsAre = config.epg_old_events*60L*60L; //hours max_events = config.epg_max_events; epg_save_frequently = config.epg_save_frequently; + epg_read_frequently = config.epg_read_frequently; if (find_executable("ntpdate").empty()){ ntp_system_cmd_prefix = find_executable("ntpd"); diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index e6ce615ca..49bafb4bd 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -69,6 +69,7 @@ CMiscMenue::CMiscMenue() epg_save_standby = NULL; epg_save_frequently = NULL; epg_read = NULL; + epg_read_frequently = NULL; epg_dir = NULL; } @@ -409,12 +410,15 @@ void CMiscMenue::showMiscSettingsMenuEpg(CMenuWidget *ms_epg) epg_save_standby = 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); epg_save_standby->setHint("", LOCALE_MENU_HINT_EPG_SAVE_STANDBY); - epg_save_frequently = new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SAVE_FREQUENTLY, &g_settings.epg_save_frequently, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, g_settings.epg_save, sectionsdConfigNotifier); + epg_save_frequently = new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SAVE_FREQUENTLY, &g_settings.epg_save_frequently, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, g_settings.epg_save, this); epg_save_frequently->setHint("", LOCALE_MENU_HINT_EPG_SAVE_FREQUENTLY); epg_read = new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_READ, &g_settings.epg_read, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, this); epg_read->setHint("", LOCALE_MENU_HINT_EPG_READ); + epg_read_frequently = new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_READ_FREQUENTLY, &g_settings.epg_read_frequently, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, g_settings.epg_read, this); + epg_read_frequently->setHint("", LOCALE_MENU_HINT_EPG_READ_FREQUENTLY); + epg_dir = new CMenuForwarder(LOCALE_MISCSETTINGS_EPG_DIR, (g_settings.epg_save || g_settings.epg_read), g_settings.epg_dir, this, "epgdir"); epg_dir->setHint("", LOCALE_MENU_HINT_EPG_DIR); @@ -462,6 +466,7 @@ void CMiscMenue::showMiscSettingsMenuEpg(CMenuWidget *ms_epg) ms_epg->addItem(epg_save_standby); ms_epg->addItem(epg_save_frequently); ms_epg->addItem(epg_read); + ms_epg->addItem(epg_read_frequently); ms_epg->addItem(epg_dir); ms_epg->addItem(GenericMenuSeparatorLine); ms_epg->addItem(mf); @@ -635,7 +640,28 @@ bool CMiscMenue::changeNotify(const neutrino_locale_t OptionName, void * /*data* } else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_MISCSETTINGS_EPG_READ)) { - epg_dir->setActive(g_settings.epg_save || g_settings.epg_read); + epg_read_frequently->setActive(g_settings.epg_read); + epg_dir->setActive(g_settings.epg_read || g_settings.epg_save); + + CNeutrinoApp::getInstance()->SendSectionsdConfig(); + + ret = menu_return::RETURN_REPAINT; + } + else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_MISCSETTINGS_EPG_READ_FREQUENTLY)) + { + g_settings.epg_read_frequently = g_settings.epg_read ? g_settings.epg_read_frequently : 0; + + CNeutrinoApp::getInstance()->SendSectionsdConfig(); + + ret = menu_return::RETURN_REPAINT; + } + else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_MISCSETTINGS_EPG_SAVE_FREQUENTLY)) + { + g_settings.epg_save_frequently = g_settings.epg_save ? g_settings.epg_save_frequently : 0; + + CNeutrinoApp::getInstance()->SendSectionsdConfig(); + + ret = menu_return::RETURN_REPAINT; } else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_MISCSETTINGS_EPG_SCAN)) { diff --git a/src/gui/miscsettings_menu.h b/src/gui/miscsettings_menu.h index 8e5848ef8..b8bbaa1a7 100644 --- a/src/gui/miscsettings_menu.h +++ b/src/gui/miscsettings_menu.h @@ -45,6 +45,7 @@ class CMiscMenue : public CMenuTarget, CChangeObserver CMenuOptionChooser * epg_save_standby; CMenuOptionChooser * epg_save_frequently; CMenuOptionChooser * epg_read; + CMenuOptionChooser * epg_read_frequently; CMenuOptionChooser * epg_scan; CMenuOptionChooser * tmdb_onoff; CMenuOptionChooser * youtube_onoff; diff --git a/src/neutrino.cpp b/src/neutrino.cpp index a983575b6..d83f98a0b 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -559,8 +559,9 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.epg_save = configfile.getBool("epg_save", false); g_settings.epg_save_standby = configfile.getBool("epg_save_standby", true); - g_settings.epg_save_frequently = configfile.getInt32("epg_save_frequently", false); + g_settings.epg_save_frequently = configfile.getInt32("epg_save_frequently", 0); g_settings.epg_read = configfile.getBool("epg_read", g_settings.epg_save); + g_settings.epg_read_frequently = configfile.getInt32("epg_read_frequently", 0); g_settings.epg_scan = configfile.getInt32("epg_scan", CEpgScan::SCAN_CURRENT); g_settings.epg_scan_mode = configfile.getInt32("epg_scan_mode", CEpgScan::MODE_OFF); // backward-compatible check @@ -1146,6 +1147,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setBool("epg_save_standby", g_settings.epg_save_standby); configfile.setInt32("epg_save_frequently", g_settings.epg_save_frequently); configfile.setBool("epg_read", g_settings.epg_read); + configfile.setInt32("epg_read_frequently", g_settings.epg_read_frequently); configfile.setInt32("epg_scan", g_settings.epg_scan); configfile.setInt32("epg_scan_mode", g_settings.epg_scan_mode); configfile.setInt32("epg_save_mode", g_settings.epg_save_mode); @@ -1839,6 +1841,7 @@ void CNeutrinoApp::MakeSectionsdConfig(CSectionsdClient::epg_config& config) config.epg_max_events = g_settings.epg_max_events; config.epg_extendedcache = g_settings.epg_extendedcache; config.epg_save_frequently = g_settings.epg_save ? g_settings.epg_save_frequently : 0; + config.epg_read_frequently = g_settings.epg_read ? g_settings.epg_read_frequently : 0; config.epg_dir = g_settings.epg_dir; config.network_ntpserver = g_settings.network_ntpserver; config.network_ntprefresh = atoi(g_settings.network_ntprefresh.c_str()); @@ -1857,6 +1860,7 @@ void CNeutrinoApp::InitZapper() struct stat my_stat; g_InfoViewer->start(); + SendSectionsdConfig(); if (g_settings.epg_read) { if(stat(g_settings.epg_dir.c_str(), &my_stat) == 0) g_Sectionsd->readSIfromXML(g_settings.epg_dir.c_str()); diff --git a/src/system/locals.h b/src/system/locals.h index 866567c49..b29341ef7 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1067,6 +1067,7 @@ typedef enum LOCALE_MENU_HINT_EPG_MAX_EVENTS, LOCALE_MENU_HINT_EPG_OLD_EVENTS, LOCALE_MENU_HINT_EPG_READ, + LOCALE_MENU_HINT_EPG_READ_FREQUENTLY, LOCALE_MENU_HINT_EPG_SAVE, LOCALE_MENU_HINT_EPG_SAVE_FREQUENTLY, LOCALE_MENU_HINT_EPG_SAVE_MODE, @@ -1541,6 +1542,7 @@ typedef enum LOCALE_MISCSETTINGS_EPG_OLD_EVENTS_HINT1, LOCALE_MISCSETTINGS_EPG_OLD_EVENTS_HINT2, LOCALE_MISCSETTINGS_EPG_READ, + LOCALE_MISCSETTINGS_EPG_READ_FREQUENTLY, LOCALE_MISCSETTINGS_EPG_SAVE, LOCALE_MISCSETTINGS_EPG_SAVE_FREQUENTLY, LOCALE_MISCSETTINGS_EPG_SAVE_MODE, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 90954b5c6..bf61c27ac 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1067,6 +1067,7 @@ const char * locale_real_names[] = "menu.hint_epg_max_events", "menu.hint_epg_old_events", "menu.hint_epg_read", + "menu.hint_epg_read_frequently", "menu.hint_epg_save", "menu.hint_epg_save_frequently", "menu.hint_epg_save_mode", @@ -1541,6 +1542,7 @@ const char * locale_real_names[] = "miscsettings.epg_old_events_hint1", "miscsettings.epg_old_events_hint2", "miscsettings.epg_read", + "miscsettings.epg_read_frequently", "miscsettings.epg_save", "miscsettings.epg_save_frequently", "miscsettings.epg_save_mode", diff --git a/src/system/settings.h b/src/system/settings.h index f32e10d47..359bbd4af 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -280,6 +280,7 @@ struct SNeutrinoSettings int epg_save_standby; int epg_save_frequently; int epg_read; + int epg_read_frequently; int epg_cache; int epg_old_events; int epg_max_events; From c84691aa502e93e04f3cfa461b32e1ae269c3796 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Nov 2016 22:45:35 +0100 Subject: [PATCH 02/12] CBEBouquetWidget: simplify hintbox calls Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/2d9775c36b7f9fc49d3a6ae8af11bc3d3822374e Author: Thilo Graf Date: 2016-11-20 (Sun, 20 Nov 2016) --- src/gui/bedit/bouqueteditor_bouquets.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index 28223aa4a..f09ad4a66 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -502,18 +502,16 @@ std::string CBEBouquetWidget::inputName(const char * const defaultName, const ne void CBEBouquetWidget::saveChanges() { - CHintBox* hintBox= new CHintBox(LOCALE_BOUQUETEDITOR_NAME, g_Locale->getText(LOCALE_BOUQUETEDITOR_SAVINGCHANGES), 480); // UTF-8 - hintBox->paint(); + CHintBox hintBox(LOCALE_BOUQUETEDITOR_NAME, g_Locale->getText(LOCALE_BOUQUETEDITOR_SAVINGCHANGES), 480); // UTF-8 + hintBox.paint(); g_Zapit->saveBouquets(); - hintBox->hide(); - delete hintBox; + hintBox.hide(); } void CBEBouquetWidget::discardChanges() { - CHintBox* hintBox= new CHintBox(LOCALE_BOUQUETEDITOR_NAME, g_Locale->getText(LOCALE_BOUQUETEDITOR_DISCARDINGCHANGES), 480); // UTF-8 - hintBox->paint(); + CHintBox hintBox(LOCALE_BOUQUETEDITOR_NAME, g_Locale->getText(LOCALE_BOUQUETEDITOR_DISCARDINGCHANGES), 480); // UTF-8 + hintBox.paint(); g_Zapit->restoreBouquets(); - hintBox->hide(); - delete hintBox; + hintBox.hide(); } From 0e4f2884604f30fc85b8408916b0886a886756c0 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Nov 2016 22:46:49 +0100 Subject: [PATCH 03/12] CFavorites: simplify hintbox calls Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/47b035849023945af39f442ebdc90d47fef66047 Author: Thilo Graf Date: 2016-11-20 (Sun, 20 Nov 2016) --- src/gui/favorites.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/favorites.cpp b/src/gui/favorites.cpp index 041cf35d1..6214ad0f7 100644 --- a/src/gui/favorites.cpp +++ b/src/gui/favorites.cpp @@ -127,14 +127,13 @@ int CFavorites::exec(CMenuTarget* parent, const std::string & actionKey) } #endif - CHintBox* hintBox = new CHintBox(LOCALE_FAVORITES_BOUQUETNAME, g_Locale->getText(LOCALE_FAVORITES_ADDCHANNEL), 380); // UTF-8 + CHintBox hintBox(LOCALE_FAVORITES_BOUQUETNAME, g_Locale->getText(LOCALE_FAVORITES_ADDCHANNEL), 380); // UTF-8 if(!show_list) - hintBox->paint(); + hintBox.paint(); status = addChannelToFavorites(show_list); - hintBox->hide(); - delete hintBox; + hintBox.hide(); // -- Display result From 659afa284a84b185bd23a548187a874706949e1c Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Nov 2016 22:49:07 +0100 Subject: [PATCH 04/12] CHDDMenuHandler: simplify and fix hintbox calls Hints were not closed after lost scope. Explicit hide() is required. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/74473d0ebe1976cbc98ae713b10e8630bdbad01a Author: Thilo Graf Date: 2016-11-20 (Sun, 20 Nov 2016) --- src/gui/hdd_menu.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index dcb79167e..8205ddae9 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -336,8 +336,8 @@ bool CHDDMenuHandler::waitfordev(std::string dev, int maxwait) void CHDDMenuHandler::showHint(std::string &message) { - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, message.c_str()); - hintBox->paint(); + CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, message.c_str()); + hintBox.paint(); uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(3); neutrino_msg_t msg; @@ -355,7 +355,7 @@ void CHDDMenuHandler::showHint(std::string &message) else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) break; } - delete hintBox; + hintBox.hide(); } void CHDDMenuHandler::setRecordPath(std::string &dev) @@ -482,8 +482,8 @@ int CHDDMenuHandler::exec(CMenuTarget* parent, const std::string &actionkey) if (actionkey[0] == 'm') { for (std::vector::iterator it = hdd_list.begin(); it != hdd_list.end(); ++it) { if (it->devname == dev) { - CHintBox * hintbox = new CHintBox(it->mounted ? LOCALE_HDD_UMOUNT : LOCALE_HDD_MOUNT, it->devname.c_str()); - hintbox->paint(); + CHintBox hintbox(it->mounted ? LOCALE_HDD_UMOUNT : LOCALE_HDD_MOUNT, it->devname.c_str()); + hintbox.paint(); if (it->mounted) umount_dev(it->devname); else @@ -491,7 +491,7 @@ int CHDDMenuHandler::exec(CMenuTarget* parent, const std::string &actionkey) it->mounted = is_mounted(it->devname.c_str()); it->cmf->setOption(it->mounted ? umount : mount); - delete hintbox; + hintbox.hide(); return menu_return::RETURN_REPAINT; } } From 6f502010b0f054dc82b049ce082a387d3e62b359 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Nov 2016 22:50:41 +0100 Subject: [PATCH 05/12] CNetworkSetup: simplify hintbox calls Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/f85270f1ed1494baa5116236661c83f78f66239b Author: Thilo Graf Date: 2016-11-20 (Sun, 20 Nov 2016) --- src/gui/network_setup.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/network_setup.cpp b/src/gui/network_setup.cpp index a3b652e36..c6748f23f 100644 --- a/src/gui/network_setup.cpp +++ b/src/gui/network_setup.cpp @@ -578,15 +578,14 @@ void CNetworkSetup::applyNetworkSettings() if (!checkForIP()) return; - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_NETWORKMENU_APPLY_SETTINGS)); // UTF-8 - hintBox->paint(); + CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_NETWORKMENU_APPLY_SETTINGS)); // UTF-8 + hintBox.paint(); networkConfig->stopNetwork(); saveNetworkSettings(); networkConfig->startNetwork(); - hintBox->hide(); - delete hintBox; + hintBox.hide(); } //open a message dialog with buttons, From ac29accd85fe125b31040891483cf6500d6a369d Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Nov 2016 22:52:46 +0100 Subject: [PATCH 06/12] CMovieBrowser: simplify and fix hintbox calls Some hints were not closed. Explicit hide() is required. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/bf05d26ae30ca7c7769062dd7d4b1f592bc5febe Author: Thilo Graf Date: 2016-11-20 (Sun, 20 Nov 2016) --- src/gui/moviebrowser/mb.cpp | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index ab8ac7443..495c270ec 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -829,11 +829,11 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) bool onefile = (actionKey == "copy_onefile"); if ((show_mode == MB_SHOW_RECORDS) && (ShowMsg(LOCALE_MESSAGEBOX_INFO, onefile ? LOCALE_MOVIEBROWSER_COPY : LOCALE_MOVIEBROWSER_COPIES, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes)) { - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_COPYING); - hintBox->paint(); - sleep(1); - hintBox->hide(); - delete hintBox; + CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_COPYING); + hintBox.paint(); + sleep(1); //??? + hintBox.hide(); + framebuffer->paintBackground(); // clear screen CMovieCut mc; bool res = mc.copyMovie(m_movieSelectionHandler, onefile); @@ -854,11 +854,11 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) #endif if ((show_mode == MB_SHOW_RECORDS) && (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_CUT, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes)) { - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_CUTTING); - hintBox->paint(); - sleep(1); - hintBox->hide(); - delete hintBox; + CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_CUTTING); + hintBox.paint(); + sleep(1); //??? + hintBox.hide(); + framebuffer->paintBackground(); // clear screen CMovieCut mc; bool res = mc.cutMovie(m_movieSelectionHandler); @@ -882,12 +882,12 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) { if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_TRUNCATE, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes) { - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_TRUNCATING); - hintBox->paint(); + CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_TRUNCATING); + hintBox.paint(); CMovieCut mc; bool res = mc.truncateMovie(m_movieSelectionHandler); - hintBox->hide(); - delete hintBox; + hintBox.hide(); + g_RCInput->clearRCMsg(); if (!res) ShowMsg(LOCALE_MESSAGEBOX_ERROR, LOCALE_MOVIEBROWSER_TRUNCATE_FAILED, CMsgBox::mbrCancel, CMsgBox::mbCancel, NEUTRINO_ICON_ERROR); @@ -1014,7 +1014,7 @@ int CMovieBrowser::exec(const char* path) snprintf(buf, sizeof(buf), format, m_movieSelectionHandler->file.Name.c_str()); CHintBox hintBox(LOCALE_MOVIEBROWSER_YT_CACHE, buf); hintBox.paint(); - sleep(1); + sleep(1); //??? hintBox.hide(); } } @@ -2408,8 +2408,8 @@ bool CMovieBrowser::onDeleteFile(MI_MOVIE_INFO *movieinfo, bool skipAsk) std::string msg = formatDeleteMsg(movieinfo, msgFont, msgBoxWidth); if ((skipAsk || !movieinfo->delAsk) || (ShowMsg(LOCALE_FILEBROWSER_DELETE, msg, CMsgBox::mbrYes, CMsgBox::mbYes|CMsgBox::mbNo, NULL, msgBoxWidth)==CMsgBox::mbrYes)) { - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MOVIEBROWSER_DELETE_INFO)); - hintBox->paint(); + CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MOVIEBROWSER_DELETE_INFO)); + hintBox.paint(); delFile(movieinfo->file); std::string cover_file = getScreenshotName(movieinfo->file.Name, S_ISDIR(movieinfo->file.Mode)); @@ -2420,7 +2420,7 @@ bool CMovieBrowser::onDeleteFile(MI_MOVIE_INFO *movieinfo, bool skipAsk) if (m_movieInfo.convertTs2XmlName(file_xml.Name)) unlink(file_xml.Name.c_str()); - delete hintBox; + hintBox.hide(); g_RCInput->clearRCMsg(); TRACE("List size: %d\n", (int)m_vMovieInfo.size()); @@ -3923,7 +3923,7 @@ int CYTCacheSelectorTarget::exec(CMenuTarget* /*parent*/, const std::string & ac snprintf(buf, sizeof(buf), format, movieBrowser->yt_failed[selected - movieBrowser->yt_failed_offset].file.Name.c_str()); CHintBox hintBox(LOCALE_MOVIEBROWSER_YT_CACHE, buf); hintBox.paint(); - sleep(1); + sleep(1); //??? hintBox.hide(); } } else From 8bbe88693f15cf50f74cd7019cfd6982dfe7b4e6 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Nov 2016 22:53:21 +0100 Subject: [PATCH 07/12] COPKGManager: simplify hintbox calls Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/318c64708dc7d445ac54d88f86ebd847ab27edf3 Author: Thilo Graf Date: 2016-11-20 (Sun, 20 Nov 2016) --- src/gui/opkg_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index b3df893e8..7c38b5f99 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -491,10 +491,10 @@ bool COPKGManager::checkUpdates(const std::string & package_name, bool show_prog int COPKGManager::doUpdate() { - CHintBox *hb = new CHintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_OPKG_UPDATE_CHECK); - hb->paint(); + CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_OPKG_UPDATE_CHECK); + hintBox.paint(); int r = execCmd(pkg_types[OM_UPDATE], CShellWindow::QUIET); - delete hb; + hintBox.hide(); if (r) { string msg = string(g_Locale->getText(LOCALE_OPKG_FAILURE_UPDATE)); msg += '\n' + tmp_str; From b159cccae6a2c3f69fa25deeb245ad9389dc75e8 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Nov 2016 22:53:53 +0100 Subject: [PATCH 08/12] showFastscanDiseqcSetup: simplify hintbox calls Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/627098d937fd0b398e96d4b591a34530d84f5ec1 Author: Thilo Graf Date: 2016-11-20 (Sun, 20 Nov 2016) --- src/gui/scan_setup.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index a4aa2599b..17017c48f 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -1488,11 +1488,11 @@ void CScanSetup::addScanMenuFastScan(CMenuWidget *fast_ScanMenu) int CScanSetup::showFastscanDiseqcSetup() { - CHintBox * hintbox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SATSETUP_FASTSCAN_AUTO_DISEQC_WAIT)); - hintbox->paint(); + CHintBox hintbox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SATSETUP_FASTSCAN_AUTO_DISEQC_WAIT)); + hintbox.paint(); CServiceScan::getInstance()->TestDiseqcConfig(scansettings.fast_op); - delete hintbox; + hintbox.hide(); CMenuWidget * sat_setup = new CMenuWidget(LOCALE_SATSETUP_DISEQC_INPUT, NEUTRINO_ICON_SETTINGS, width); sat_setup->addIntroItems(); From deb6aec16af6944cd5c0df6ed0fc1f44ffb79dda Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Nov 2016 22:54:51 +0100 Subject: [PATCH 09/12] cTmdb: simplyfy hintbox calls Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/43383329a736d17ed10aa95ea4d0ec4a62af899b Author: Thilo Graf Date: 2016-11-20 (Sun, 20 Nov 2016) --- src/gui/tmdb.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/gui/tmdb.cpp b/src/gui/tmdb.cpp index 0b8556440..e4e65b70a 100644 --- a/src/gui/tmdb.cpp +++ b/src/gui/tmdb.cpp @@ -63,18 +63,15 @@ cTmdb::cTmdb(std::string epgtitle) key = g_settings.tmdb_api_key; #endif - CHintBox* box = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_TMDB_READ_DATA)); - box->paint(); + CHintBox hintbox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_TMDB_READ_DATA)); + hintbox.paint(); std::string lang = Lang2ISO639_1(g_settings.language); GetMovieDetails(lang); if ((minfo.result < 1 || minfo.overview.empty()) && lang != "en") GetMovieDetails("en"); - if (box != NULL) { - box->hide(); - delete box; - } + hintbox.hide(); } cTmdb::~cTmdb() From 4b15828631b73beec823c8f911b984d026137768 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Nov 2016 22:56:33 +0100 Subject: [PATCH 10/12] CUpnpBrowserGui: simplify hintbox calls Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/c47d26637b4d93a72c42152980a46306c87fa9cc Author: Thilo Graf Date: 2016-11-20 (Sun, 20 Nov 2016) --- src/gui/upnpbrowser.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index 3d80069a1..59221c059 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -245,19 +245,19 @@ bool CUpnpBrowserGui::discoverDevices() if (!m_devices.empty()) return true; - CHintBox *scanBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_UPNPBROWSER_SCANNING)); // UTF-8 - scanBox->paint(); + CHintBox hintbox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_UPNPBROWSER_SCANNING)); // UTF-8 + hintbox.paint(); try { m_devices = m_socket->Discover("urn:schemas-upnp-org:service:ContentDirectory:1"); } catch (std::runtime_error error) { - delete scanBox; + hintbox.hide(); DisplayErrorMessage(error.what()); return false; } - delete scanBox; + hintbox.hide(); if (m_devices.empty()) { DisplayInfoMessage(g_Locale->getText(LOCALE_UPNPBROWSER_NOSERVERS)); From 02ae0963671ad4cc4f7d61111f6c3a734d5959c7 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Nov 2016 22:58:30 +0100 Subject: [PATCH 11/12] CNeutrinoApp: simplify and fix hintbox calls Some hints were not closed after delete. Explicit hide()is required. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/5db26ef6646af8f56d04bab1b5c62564e4ae0ddf Author: Thilo Graf Date: 2016-11-20 (Sun, 20 Nov 2016) --- src/neutrino.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index d83f98a0b..c6bc48e70 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2233,6 +2233,7 @@ TIMER_STOP("################################## after all ####################### //flash.enableNotify(false); flash.exec(NULL, "inet"); } + hintBox->hide(); delete hintBox; } RealRun(); @@ -4025,8 +4026,8 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) returnval = menu_return::RETURN_EXIT_ALL; } else if(actionKey=="savesettings") { - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MAINSETTINGS_SAVESETTINGSNOW_HINT)); // UTF-8 - hintBox->paint(); + CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MAINSETTINGS_SAVESETTINGSNOW_HINT)); // UTF-8 + hintBox.paint(); saveSetup(NEUTRINO_SETTINGS_FILE); @@ -4038,20 +4039,18 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) //g_Sectionsd->setEventsAreOldInMinutes((unsigned short) (g_settings.epg_old_hours*60)); //g_Sectionsd->setHoursToCache((unsigned short) (g_settings.epg_cache_days*24)); - hintBox->hide(); - delete hintBox; + hintBox.hide(); } else if(actionKey=="recording") { setupRecordingDevice(); } else if(actionKey=="reloadplugins") { - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SERVICEMENU_GETPLUGINS_HINT)); - hintBox->paint(); + CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SERVICEMENU_GETPLUGINS_HINT)); + hintBox.paint(); g_PluginList->loadPlugins(); - hintBox->hide(); - delete hintBox; + hintBox.hide(); } else if(actionKey=="nkplayback" || actionKey=="ytplayback" || actionKey=="tsmoviebrowser" || actionKey=="fileplayback") { frameBuffer->Clear(); @@ -4702,7 +4701,9 @@ void CNeutrinoApp::CheckFastScan(bool standby, bool reload) scanSettings.fst_version = CServiceScan::getInstance()->GetFstVersion(); scanSettings.saveSettings(NEUTRINO_SCAN_SETTINGS_FILE); } - delete fhintbox; + if (fhintbox){ + fhintbox->hide(); delete fhintbox; + } if (standby) CVFD::getInstance()->setMode(CVFD::MODE_STANDBY); } From 2e13b9647e066d6d74707c2a89ae70f4dbbcd57b Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Nov 2016 23:14:59 +0100 Subject: [PATCH 12/12] CTestMenu: add form sample Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/d6c5bc2d28f047a370fe8dac349ba2ba58cf331b Author: Thilo Graf Date: 2016-11-20 (Sun, 20 Nov 2016) --- src/gui/test_menu.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index 64035b72c..c461a9afe 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -494,6 +494,39 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) form->paint(); return res; } + else if (actionKey == "form_blink_item"){ + if (form == NULL){ + form = new CComponentsForm(); + form->setColorBody(COL_DARK_GRAY); + form->setDimensionsAll(100, 100, 250, 100); + form->setFrameThickness(2); + form->setColorFrame(COL_WHITE); + //form->doPaintBg(false); + + CComponentsPicture *ptmp = new CComponentsPicture(10, 10, NEUTRINO_ICON_HINT_INFO); + ptmp->doPaintBg(false); + ptmp->SetTransparent(CFrameBuffer::TM_BLACK); + form->addCCItem(ptmp); + + CComponentsText *text = new CComponentsText(80, 30, 100, 50, "Info"); + text->doPaintBg(false); + form->addCCItem(text); + + form->paint0(); + ptmp->kill(); + } + + if (static_cast(form->getCCItem(0))-> paintBlink(500000, true)){ + ShowHint("Testmenu: Blink","Testmenu: Blinking embedded image ...", 700, 10); + } + if (form->getCCItem(0)->cancelBlink()){ + ShowHint("Testmenu: Blink","Testmenu: Blinking embedded image stopped ...", 700, 2); + } + + form->kill(); + delete form; form = NULL; + return res; + } else if (actionKey == "text"){ if (txt == NULL) txt = new CComponentsText(); @@ -968,6 +1001,7 @@ void CTestMenu::showCCTests(CMenuWidget *widget) widget->addItem(new CMenuForwarder("Picture", true, NULL, this, "picture")); widget->addItem(new CMenuForwarder("Channel-Logo", true, NULL, this, "channellogo")); widget->addItem(new CMenuForwarder("Form", true, NULL, this, "form")); + widget->addItem(new CMenuForwarder("Form with blinking item", true, NULL, this, "form_blink_item")); widget->addItem(new CMenuForwarder("Text", true, NULL, this, "text")); widget->addItem(new CMenuForwarder("Blinking Text", true, NULL, this, "blinking_text")); widget->addItem(new CMenuForwarder("Header", true, NULL, this, "header"));