From c256ca266a1abd5bdcf74c88f11b2bbab48628f8 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 22 Jan 2017 23:27:30 +0100 Subject: [PATCH 01/20] hintbox: restore proper handling of up/down keys When no scrollbar is present, just pass through up/down keys instead of only canceling the hintbox. This restores the behaviour before commit 11b3307251. Prominent examle is the "channel not available" popup which prevented further channel switching until canceled. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/d74afdf6ff521a96abb15520069b6a56460e7e63 Author: Stefan Seyfried Date: 2017-01-22 (Sun, 22 Jan 2017) --- src/gui/widget/hintbox.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/gui/widget/hintbox.cpp b/src/gui/widget/hintbox.cpp index 9be2aae6f..8e513756a 100644 --- a/src/gui/widget/hintbox.cpp +++ b/src/gui/widget/hintbox.cpp @@ -219,16 +219,13 @@ int CHintBox::exec() { res = messages_return::cancel_all; } - else if ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down)) + else if (enable_txt_scroll && (msg == CRCInput::RC_up || msg == CRCInput::RC_down)) { - if (enable_txt_scroll){ - if (msg == CRCInput::RC_up) - this->scroll_up(); - else - this->scroll_down(); - } + /* if ! enable_txt_scroll, fall through to last else branch instead */ + if (msg == CRCInput::RC_up) + this->scroll_up(); else - res = messages_return::cancel_all; + this->scroll_down(); } else if (CNeutrinoApp::getInstance()->listModeKey(msg)){ // do nothing //TODO: if passed rc messages are ignored rc messaages: has no effect here too!! From 52b393cee94e26a356b28a04237644dfebc7e1dc Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 28 Jan 2017 14:03:27 +0100 Subject: [PATCH 02/20] opkg_manager: use system-update script if available opkg has several problems with complex system updates, especially when having to update itself and with the package ordering during update To avoid hard coding the workarounds into neutrino, just call a script named "system-update" (if available) instead of "opkg upgrade". This script can be tuned to the specific target and its problems. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/904788b99209ced9bff4aa6dd113cbdd257be4e5 Author: Stefan Seyfried Date: 2017-01-28 (Sat, 28 Jan 2017) --- src/gui/opkg_manager.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index 2d014704f..48ea56bb3 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -11,7 +11,7 @@ Adaptions: Copyright (C) 2013 martii gitorious.org/neutrino-mp/martiis-neutrino-mp - Copyright (C) 2015-2016 Stefan Seyfried + Copyright (C) 2015-2017 Stefan Seyfried License: GPL @@ -79,6 +79,11 @@ #define OPKG_CONFIG_FILE "/etc/opkg/opkg.conf.borken" #endif +/* script to call instead of "opkg upgrade" + * opkg fails to gracefully self-upgrade, and additionally has some ordering issues + */ +#define SYSTEM_UPDATE "system-update" + using namespace std; enum @@ -97,7 +102,7 @@ enum OM_MAX }; -static const string pkg_types[OM_MAX] = +static string pkg_types[OM_MAX] = { OPKG_CL " list ", OPKG_CL " list-installed ", @@ -622,6 +627,11 @@ bool COPKGManager::hasOpkgSupport() return false; } + if (! find_executable(SYSTEM_UPDATE).empty()) { + dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d] " SYSTEM_UPDATE " script found\n", __func__, __LINE__); + pkg_types[OM_UPGRADE] = SYSTEM_UPDATE; + } + #if 0 /* If directory /var/lib/opkg resp. /opt/opkg does not exist, it is created by opkg itself */ From 0b2693c40ade45561964077a6714d2b5bae9dd8d Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 28 Jan 2017 14:06:39 +0100 Subject: [PATCH 03/20] opkg_manager: avoid the zombie apocalypse, use waitpid() Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/4dc1efbf2c09ff819d23aeddf867eb16422ca3fb Author: Stefan Seyfried Date: 2017-01-28 (Sat, 28 Jan 2017) --- src/gui/opkg_manager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index 48ea56bb3..3bf5fd2dc 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -789,6 +789,8 @@ void COPKGManager::getPkgData(const int pkg_content_id) } } + waitpid(pid, NULL, 0); /* beware of the zombie apocalypse! */ + fclose(f); } From b4b3ccff85443108f341ce72178159f21cd3b357 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 28 Jan 2017 22:56:05 +0100 Subject: [PATCH 04/20] shellwindow: use time_monotonic_ms() Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/207e03bf6fd27086d9362a16dfce65c10c8f51ed Author: Stefan Seyfried Date: 2017-01-28 (Sat, 28 Jan 2017) --- src/gui/widget/shellwindow.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/gui/widget/shellwindow.cpp b/src/gui/widget/shellwindow.cpp index 78fa6d23e..ddd850351 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -7,7 +7,7 @@ Implementation: Copyright (C) 2013 martii gitorious.org/neutrino-mp/martiis-neutrino-mp - Copyright (C) 2015 Stefan Seyfried + Copyright (C) 2015-2017 Stefan Seyfried License: GPL @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -103,22 +104,19 @@ void CShellWindow::exec() fds.events = POLLIN | POLLHUP | POLLERR; fcntl(fds.fd, F_SETFL, fcntl(fds.fd, F_GETFL, 0) | O_NONBLOCK); - struct timeval tv; - gettimeofday(&tv,NULL); - uint64_t lastPaint = (uint64_t) tv.tv_usec + (uint64_t)((uint64_t) tv.tv_sec * (uint64_t) 1000000); + time_t lastPaint = time_monotonic_ms(); bool ok = true, nlseen = false, dirty = false, incomplete = false; char output[1024]; std::string txt = ""; std::string line = ""; do { - uint64_t now; + time_t now; fds.revents = 0; int r = poll(&fds, 1, 300); if (r > 0) { if (!feof(f)) { - gettimeofday(&tv,NULL); - now = (uint64_t) tv.tv_usec + (uint64_t)((uint64_t) tv.tv_sec * (uint64_t) 1000000); + now = time_monotonic_ms(); unsigned int lines_read = 0; while (fgets(output, sizeof(output), f)) { @@ -178,7 +176,7 @@ void CShellWindow::exec() first = false; txt += *it; } - if (((lines_read == lines_max) && (lastPaint + 100000 < now)) || (lastPaint + 250000 < now)) { + if (((lines_read >= lines_max) && (lastPaint + 100 < now)) || (lastPaint + 250 < now)) { textBox->setText(&txt, textBox->getWindowsPos().iWidth, false); if (!textBox->isPainted()) if (mode & VERBOSE) textBox->paint(); @@ -192,9 +190,8 @@ void CShellWindow::exec() } else if (r < 0) ok = false; - gettimeofday(&tv,NULL); - now = (uint64_t) tv.tv_usec + (uint64_t)((uint64_t) tv.tv_sec * (uint64_t) 1000000); - if (!ok || (r < 1 && dirty && lastPaint + 250000 < now)) { + now = time_monotonic_ms(); + if (!ok || (r < 1 && dirty && lastPaint + 250 < now)) { textBox->setText(&txt, textBox->getWindowsPos().iWidth, false); if (!textBox->isPainted()) if (mode & VERBOSE) textBox->paint(); From 54b1b30e5ad1507fcac8a586005c2455c07a6ad3 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 28 Jan 2017 23:17:03 +0100 Subject: [PATCH 05/20] helpers: add run_pty() function This runs an external command inside a pty. Running inside a pty, external commands using stdio(3) will disable stdout buffering when running from a terminal, which is often desirable. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/9d78d7072d11294ed0f4a51cb4955a2147115c7a Author: Stefan Seyfried Date: 2017-01-28 (Sat, 28 Jan 2017) --- src/Makefile.am | 1 + src/system/helpers.cpp | 19 ++++++++++++++++++- src/system/helpers.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 8af131987..e2f8a3ba6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,6 +123,7 @@ neutrino_LDADD = \ $(PUGIXML_LIBS) \ -ldvbsi++ \ -ljpeg \ + -lutil \ -lOpenThreads \ -lrt -lpthread diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index f668dd735..2f207ac2b 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -4,7 +4,7 @@ License: GPL (C) 2012-2013 the neutrino-hd developers - (C) 2012-2015 Stefan Seyfried + (C) 2012-2017 Stefan Seyfried 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 @@ -30,6 +30,7 @@ #include #include #include +#include /* forkpty*/ #include #include #include @@ -222,6 +223,22 @@ FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type) } return(fp); } + +int run_pty(pid_t &pid, const char *cmdstring) +{ + int master = -1; + if ((pid = forkpty(&master, NULL, NULL, NULL)) < 0) + return -1; + else if (pid == 0) { + int maxfd = getdtablesize(); + for(int i = 3; i < maxfd; i++) + close(i); + execl("/bin/sh", "sh", "-c", cmdstring, (char *)0); + exit(0); + } + return master; +} + #if 0 int mkdirhier(const char *pathname, mode_t mode) { diff --git a/src/system/helpers.h b/src/system/helpers.h index 431851d76..53205f8e1 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -41,6 +41,7 @@ int my_system(const char * cmd); int my_system(int argc, const char *arg, ...); /* argc is number of arguments including command */ FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type); +int run_pty(pid_t &pid, const char *cmdstring); int safe_mkdir(const char * path); inline int safe_mkdir(std::string path) { return safe_mkdir(path.c_str()); } From 9995b2f1dfaae98a709d332db87097c1a768f84a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 28 Jan 2017 23:37:45 +0100 Subject: [PATCH 06/20] textbox: fix output for BOTTOM mode If more text is added to a textbox than fits into the window, the last lines are stripped. In BOTTOM (and non-SCROLL) mode, it makes more sense to strip the first lines. This is used by shellwindow, e.g. in package management menu. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/f1a0cc2351bad4dfe8275983a7d4ad8ad61f1f2e Author: Stefan Seyfried Date: 2017-01-28 (Sat, 28 Jan 2017) --- src/gui/widget/textbox.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 4750de544..043ffbaac 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -679,11 +679,14 @@ void CTextBox::refreshText(void) if (m_nMode & TOP) // move to top of frame y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * m_nLinesPerPage) >> 1); - else if (m_nMode & BOTTOM) + else if (m_nMode & BOTTOM) { + /* if BOTTOM && !SCROLL, show the last lines if more than one page worth of text is in cLineArray */ + if (!(m_nMode & SCROLL) && (m_nNrOfLines > m_nLinesPerPage)) + m_nCurrentLine = m_nNrOfLines - m_nLinesPerPage; // move to bottom of frame y += m_cFrameTextRel.iHeight - (lines > 1 ? (lines - 1)*m_nFontTextHeight : 0) - text_Vborder_width; //m_nFontTextHeight + text_Vborder_width /*- ((m_cFrameTextRel.iHeight + m_nFontTextHeight*/ * m_nLinesPerPage/*) >> 1)*/; - else + } else // fit into mid of frame space y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * lines) >> 1); From 8408d6e816287d029bb66fbb1e394743555e9054 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 28 Jan 2017 23:47:01 +0100 Subject: [PATCH 07/20] shellwindow: use run_pty() instead of my_popen() Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/c388c7029e29716d4a087c3762dbd931784c80c5 Author: Stefan Seyfried Date: 2017-01-28 (Sat, 28 Jan 2017) --- src/gui/widget/shellwindow.cpp | 37 +++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/gui/widget/shellwindow.cpp b/src/gui/widget/shellwindow.cpp index ddd850351..f4a1509aa 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -64,6 +64,24 @@ void CShellWindow::setCommand(const std::string &Command, const int Mode, int* R exec(); } +static int read_line(int fd, struct pollfd *fds, char *b, size_t sz) +{ + int ret; + size_t i = 0; + while ((ret = read(fd, b + i, 1)) > 0) { + i++; + if (b[i - 1] == '\n') + break; + if (i >= sz) + break; + fds->revents = 0; + if (poll(fds, 1, 300) < 1) + break; + } + b[i] = 0; + return i; +} + void CShellWindow::exec() { std::string cmd; @@ -81,11 +99,11 @@ void CShellWindow::exec() else { pid_t pid = 0; cmd = command + " 2>&1"; - FILE *f = my_popen(pid, cmd.c_str(), "r"); - if (!f) { + int f = run_pty(pid, cmd.c_str()); + if (f < 0) { if (res) *res = -1; - dprintf(DEBUG_NORMAL, "[CShellWindow] [%s:%d] Error! my_popen errno: %d command: %s\n", __func__, __LINE__, errno, cmd.c_str()); + dprintf(DEBUG_NORMAL, "[CShellWindow] [%s:%d] Error! run_pty errno: %d command: %s\n", __func__, __LINE__, errno, cmd.c_str()); return; } @@ -100,7 +118,7 @@ void CShellWindow::exec() textBox->enableSaveScreen(false); } struct pollfd fds; - fds.fd = fileno(f); + fds.fd = f; fds.events = POLLIN | POLLHUP | POLLERR; fcntl(fds.fd, F_SETFL, fcntl(fds.fd, F_GETFL, 0) | O_NONBLOCK); @@ -115,11 +133,9 @@ void CShellWindow::exec() fds.revents = 0; int r = poll(&fds, 1, 300); if (r > 0) { - if (!feof(f)) { - now = time_monotonic_ms(); - + if (fds.revents & POLLIN) { unsigned int lines_read = 0; - while (fgets(output, sizeof(output), f)) { + while (read_line(f, &fds, output, sizeof(output)-1)) { char *outputp = output; dirty = true; @@ -131,7 +147,9 @@ void CShellWindow::exec() *outputp = 0; break; case '\r': +#if 0 outputp = output; +#endif break; case '\n': lines_read++; @@ -166,6 +184,7 @@ void CShellWindow::exec() else dprintf(DEBUG_NORMAL, "[CShellWindow] [%s:%d] res=NULL ok=%d\n", __func__, __LINE__, ok); + now = time_monotonic_ms(); if (lines.size() > lines_max) lines.pop_front(); txt = ""; @@ -205,7 +224,7 @@ void CShellWindow::exec() textBox->setText(&txt, textBox->getWindowsPos().iWidth, false); } - fclose(f); + close(f); int s; errno = 0; int r = waitpid(pid, &s, 0); From 9106fce21b216b39fdc287c059e1b340d7614a20 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 29 Jan 2017 00:03:52 +0100 Subject: [PATCH 08/20] shellwindow: ensure text is set correctly and only when necessary Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/61bd0c53b724179e394791ea2fa377720bea0128 Author: Stefan Seyfried Date: 2017-01-29 (Sun, 29 Jan 2017) --- src/gui/widget/shellwindow.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gui/widget/shellwindow.cpp b/src/gui/widget/shellwindow.cpp index f4a1509aa..d8b69068a 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -82,6 +82,16 @@ static int read_line(int fd, struct pollfd *fds, char *b, size_t sz) return i; } +static std::string lines2txt(list &lines) +{ + std::string txt = ""; + for (std::list::const_iterator it = lines.begin(), end = lines.end(); it != end; ++it) { + txt += *it; + txt += '\n'; + } + return txt; +} + void CShellWindow::exec() { std::string cmd; @@ -187,15 +197,8 @@ void CShellWindow::exec() now = time_monotonic_ms(); if (lines.size() > lines_max) lines.pop_front(); - txt = ""; - bool first = true; - for (std::list::const_iterator it = lines.begin(), end = lines.end(); it != end; ++it) { - if (!first) - txt += '\n'; - first = false; - txt += *it; - } if (((lines_read >= lines_max) && (lastPaint + 100 < now)) || (lastPaint + 250 < now)) { + txt = lines2txt(lines); textBox->setText(&txt, textBox->getWindowsPos().iWidth, false); if (!textBox->isPainted()) if (mode & VERBOSE) textBox->paint(); @@ -211,6 +214,7 @@ void CShellWindow::exec() now = time_monotonic_ms(); if (!ok || (r < 1 && dirty && lastPaint + 250 < now)) { + txt = lines2txt(lines); textBox->setText(&txt, textBox->getWindowsPos().iWidth, false); if (!textBox->isPainted()) if (mode & VERBOSE) textBox->paint(); @@ -220,6 +224,7 @@ void CShellWindow::exec() } while(ok); if (mode & VERBOSE) { + txt = lines2txt(lines); txt += "\n...ready"; textBox->setText(&txt, textBox->getWindowsPos().iWidth, false); } From 4168ff989c100f2e4956a4cb95e7beb8aeb74917 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 29 Jan 2017 00:06:26 +0100 Subject: [PATCH 09/20] shellwindow: reduce update interval Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/37ac394cac743dc7950891836fcb6acd3e9a9c25 Author: Stefan Seyfried Date: 2017-01-29 (Sun, 29 Jan 2017) --- src/gui/widget/shellwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widget/shellwindow.cpp b/src/gui/widget/shellwindow.cpp index d8b69068a..931390243 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -197,7 +197,7 @@ void CShellWindow::exec() now = time_monotonic_ms(); if (lines.size() > lines_max) lines.pop_front(); - if (((lines_read >= lines_max) && (lastPaint + 100 < now)) || (lastPaint + 250 < now)) { + if (((lines_read >= lines_max) && (lastPaint + 100 < now)) || (lastPaint + 500 < now)) { txt = lines2txt(lines); textBox->setText(&txt, textBox->getWindowsPos().iWidth, false); if (!textBox->isPainted()) @@ -213,7 +213,7 @@ void CShellWindow::exec() ok = false; now = time_monotonic_ms(); - if (!ok || (r < 1 && dirty && lastPaint + 250 < now)) { + if (!ok || (r < 1 && dirty && lastPaint + 500 < now)) { txt = lines2txt(lines); textBox->setText(&txt, textBox->getWindowsPos().iWidth, false); if (!textBox->isPainted()) From 4cbc19e781c345636af89bbf8666d380e6b58438 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 29 Jan 2017 01:52:08 +0100 Subject: [PATCH 10/20] opkg_manager: don't set error flag for shellwindow The shellwindow exits if the "ok" flag is set to false, aborting further execution of more commands. This hurts with system-update script. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/0c8d7d7d17672cb4e487db93e1965588f5f29cd8 Author: Stefan Seyfried Date: 2017-01-29 (Sun, 29 Jan 2017) --- 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 3bf5fd2dc..e7e568c43 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -923,13 +923,13 @@ void COPKGManager::handleShellOutput(string* cur_line, int* res, bool* ok) //download error: if (line.find("opkg_download:") != string::npos){ *res = OM_DOWNLOAD_ERR; - *ok = false; + //*ok = false; return; } //not enough space if (line.find("No space left on device") != string::npos){ *res = OM_OUT_OF_SPACE_ERR; - *ok = false; + //*ok = false; return; } //deps @@ -942,7 +942,7 @@ void COPKGManager::handleShellOutput(string* cur_line, int* res, bool* ok) if (*ok){ dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d] ERROR: unhandled error %s\n", __func__, __LINE__, line.c_str()); *res = OM_UNKNOWN_ERR; - *ok = false; + //*ok = false; return; } From 053aae2e5dd164198f51503263a070ae386547f4 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 29 Jan 2017 01:58:24 +0100 Subject: [PATCH 11/20] opkg_manager: make console output more useful Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/7fd5149f01c4d1390bc0041a172d1daced7b3a49 Author: Stefan Seyfried Date: 2017-01-29 (Sun, 29 Jan 2017) --- src/gui/opkg_manager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index e7e568c43..dcd54d121 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -896,9 +896,12 @@ void COPKGManager::handleShellOutput(string* cur_line, int* res, bool* ok) if (pos2 != string::npos) has_err = true; + dprintf(DEBUG_NORMAL, "[COPKGManager:%d] %s\n", __LINE__, line.c_str()); //check for collected errors and set res value if (has_err){ + /* all lines printed already dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d] result: %s\n", __func__, __LINE__, line.c_str()); + */ /*duplicate option cache: option is defined in OPKG_CL_CONFIG_OPTIONS, * NOTE: if found first cache option in the opkg.conf file, this will be preferred and it's not really an error! @@ -940,7 +943,7 @@ void COPKGManager::handleShellOutput(string* cur_line, int* res, bool* ok) } //unknown error if (*ok){ - dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d] ERROR: unhandled error %s\n", __func__, __LINE__, line.c_str()); + dprintf(DEBUG_DEBUG, "[COPKGManager] [%s - %d] ERROR: unhandled error %s\n", __func__, __LINE__, line.c_str()); *res = OM_UNKNOWN_ERR; //*ok = false; return; From be69a27a634d21d705cbb3082b57c9d01b75b3e9 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 29 Jan 2017 01:58:56 +0100 Subject: [PATCH 12/20] opkg_manager: add magic string to reset error flags ... to be used by sytem-update script Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/9d6bbc45522ebf662441316991afd8ddfe89edc4 Author: Stefan Seyfried Date: 2017-01-29 (Sun, 29 Jan 2017) --- src/gui/opkg_manager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index dcd54d121..5d94bc71f 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -941,6 +941,13 @@ void COPKGManager::handleShellOutput(string* cur_line, int* res, bool* ok) *ok = false; return; } + /* hack */ + if (line.find("system-update: err_reset") != string::npos) { + *res = OM_SUCCESS; + *ok = true; + has_err = false; + return; + } //unknown error if (*ok){ dprintf(DEBUG_DEBUG, "[COPKGManager] [%s - %d] ERROR: unhandled error %s\n", __func__, __LINE__, line.c_str()); From 35bce4365b71b34478e5cd1910b4fac67ca9ac7e Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 29 Jan 2017 01:59:40 +0100 Subject: [PATCH 13/20] opkg_manager: make error messages less cryptic the errno has nothing to do with the error that happened, so do not use it for the error message Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/b37faafc80013e714db1e54a28c6240e26a7710d Author: Stefan Seyfried Date: 2017-01-29 (Sun, 29 Jan 2017) --- src/gui/opkg_manager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index 5d94bc71f..df327761e 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -221,7 +221,10 @@ int COPKGManager::exec(CMenuTarget* parent, const string &actionKey) { string pkg_name = fileBrowser.getSelectedFile()->Name; if (!installPackage(pkg_name)) + showError(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL), "", pkg_name); + /* errno is never set properly, the string is totally useless. showError(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL), strerror(errno), pkg_name); + */ *local_dir = fileBrowser.getCurrentDir(); refreshMenu(); @@ -233,7 +236,10 @@ int COPKGManager::exec(CMenuTarget* parent, const string &actionKey) parent->hide(); int r = execCmd(actionKey, CShellWindow::VERBOSE | CShellWindow::ACKNOWLEDGE_EVENT); if (r) { + /* errno is never set properly, the string is totally useless. showError(g_Locale->getText(LOCALE_OPKG_FAILURE_UPGRADE), strerror(errno), actionKey); + */ + showError(g_Locale->getText(LOCALE_OPKG_FAILURE_UPGRADE), "", actionKey); } else installed = true; refreshMenu(); @@ -1007,7 +1013,10 @@ bool COPKGManager::installPackage(const string& pkg_name, string options, bool f break; } default: + showError(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL), "", pkg_types[OM_INSTALL] + opts + pkg_name); + /* errno / strerror considered useless here showError(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL), strerror(errno), pkg_types[OM_INSTALL] + opts + pkg_name); + */ } }else{ if (force_configure) From e8bbda3eea778b462427fc49d7fb5de7130762fe Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 29 Jan 2017 02:00:50 +0100 Subject: [PATCH 14/20] upkg_manager: comment out stale code Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/448b5dc7c7a21728051db64326d9f65d174c3993 Author: Stefan Seyfried Date: 2017-01-29 (Sun, 29 Jan 2017) --- src/gui/opkg_manager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index df327761e..229bad58d 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -962,10 +962,13 @@ void COPKGManager::handleShellOutput(string* cur_line, int* res, bool* ok) return; } +#if 0 + /* never reached */ if (!has_err){ *ok = true; *res = OM_SUCCESS; } +#endif } *res = _res; From 43eb01a810dcbc7afb8a87e9f87399bafd25d00d Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 1 Feb 2017 09:10:06 +0100 Subject: [PATCH 15/20] CRecordManager: remove static error messages Static message window expects user interaction but in this case user could be absent. and recordings could be running out of control. These messages are only warnings and "to slow" warning is optional. To avoid uncontrolled behavior of recordings, it should be enough to use messages with simple timeout. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/3387bcf2c4f0de54abea7f5cb3067d84b1af3716 Author: Thilo Graf Date: 2017-02-01 (Wed, 01 Feb 2017) --- src/driver/record.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/driver/record.cpp b/src/driver/record.cpp index f76cecf3b..12b62c13f 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -1325,10 +1325,10 @@ int CRecordManager::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data if ((have_err & REC_STATUS_OVERFLOW) && error_display) { error_display = false; warn_display = false; - DisplayErrorMessage(g_Locale->getText(LOCALE_STREAMING_OVERFLOW)); + ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_STREAMING_OVERFLOW, 700, 60, NEUTRINO_ICON_ERROR, NULL, CComponentsHeader::CC_BTN_EXIT); } else if (g_settings.recording_slow_warning && warn_display) { warn_display = false; - DisplayErrorMessage(g_Locale->getText(LOCALE_STREAMING_SLOW)); + ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_STREAMING_SLOW, 700, 60, NEUTRINO_ICON_ERROR, NULL, CComponentsHeader::CC_BTN_EXIT); } } return messages_return::handled; From 14df18cc867e9bb8327101282a69fcb335edbe60 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 1 Feb 2017 09:36:28 +0100 Subject: [PATCH 16/20] CRecordManager: revert warn message for stream overflow It's an error not a warning! Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/721f85deba24584e987f4dfabf395cccdd00b820 Author: Thilo Graf Date: 2017-02-01 (Wed, 01 Feb 2017) --- src/driver/record.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 12b62c13f..517ecff64 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -1325,7 +1325,7 @@ int CRecordManager::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data if ((have_err & REC_STATUS_OVERFLOW) && error_display) { error_display = false; warn_display = false; - ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_STREAMING_OVERFLOW, 700, 60, NEUTRINO_ICON_ERROR, NULL, CComponentsHeader::CC_BTN_EXIT); + DisplayErrorMessage(g_Locale->getText(LOCALE_STREAMING_OVERFLOW)); } else if (g_settings.recording_slow_warning && warn_display) { warn_display = false; ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_STREAMING_SLOW, 700, 60, NEUTRINO_ICON_ERROR, NULL, CComponentsHeader::CC_BTN_EXIT); From 23811afa4653a7c25f932fd7b6c32b53034b6e14 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 1 Feb 2017 11:34:00 +0100 Subject: [PATCH 17/20] Messages: add timeout parameter for error and info messages I'm not sure if it is a good idea to set a global timeout for all error messages. This should be decided for respective cases. Timeout for info messages should not be a problem. The default timeout is set here as global. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/b8dabf2bf96075705d8ef5e0a56a5e5a5b569633 Author: Thilo Graf Date: 2017-02-01 (Wed, 01 Feb 2017) --- src/gui/widget/msgbox.cpp | 24 ++++++++++++------------ src/gui/widget/msgbox.h | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/gui/widget/msgbox.cpp b/src/gui/widget/msgbox.cpp index dc5b0b50c..25deb70f8 100644 --- a/src/gui/widget/msgbox.cpp +++ b/src/gui/widget/msgbox.cpp @@ -542,32 +542,32 @@ int ShowMsg( const std::string & Title, return (result); } -void DisplayErrorMessage(const char * const ErrorMsg, const neutrino_locale_t& caption, const int& Text_mode) +void DisplayErrorMessage(const char * const ErrorMsg, const neutrino_locale_t& caption, const int &Timeout , const int& Text_mode) { - ShowMsg(caption, ErrorMsg, CMsgBox::mbrCancel, CMsgBox::mbBack, NEUTRINO_ICON_ERROR, 500, NO_TIMEOUT, false, Text_mode, COL_RED); + ShowMsg(caption, ErrorMsg, CMsgBox::mbrCancel, CMsgBox::mbBack, NEUTRINO_ICON_ERROR, 500, Timeout, false, Text_mode, COL_RED); } -void DisplayErrorMessage(const char * const ErrorMsg, const std::string& caption, const int& Text_mode) +void DisplayErrorMessage(const char * const ErrorMsg, const std::string& caption, const int &Timeout , const int& Text_mode) { - ShowMsg(caption, ErrorMsg, CMsgBox::mbrCancel, CMsgBox::mbBack, NEUTRINO_ICON_ERROR, 500, NO_TIMEOUT, false, Text_mode, COL_RED); + ShowMsg(caption, ErrorMsg, CMsgBox::mbrCancel, CMsgBox::mbBack, NEUTRINO_ICON_ERROR, 500, Timeout, false, Text_mode, COL_RED); } -void DisplayErrorMessage(const char * const ErrorMsg, const int& Text_mode) +void DisplayErrorMessage(const char * const ErrorMsg, const int &Timeout, const int& Text_mode) { - DisplayErrorMessage(ErrorMsg, LOCALE_MESSAGEBOX_ERROR, Text_mode); + DisplayErrorMessage(ErrorMsg, LOCALE_MESSAGEBOX_ERROR, Timeout, Text_mode); } -void DisplayInfoMessage(const char * const InfoMsg, const neutrino_locale_t& caption, const int& Text_mode, fb_pixel_t color_frame) +void DisplayInfoMessage(const char * const InfoMsg, const neutrino_locale_t& caption, const int& Timeout, const int& Text_mode, fb_pixel_t color_frame) { - ShowMsg(caption, InfoMsg, CMsgBox::mbrBack, CMsgBox::mbOk, NEUTRINO_ICON_INFO, 500, NO_TIMEOUT, false, Text_mode, color_frame); + ShowMsg(caption, InfoMsg, CMsgBox::mbrBack, CMsgBox::mbOk, NEUTRINO_ICON_INFO, 500, Timeout, false, Text_mode, color_frame); } -void DisplayInfoMessage(const char * const InfoMsg, const std::string& caption, const int& Text_mode, fb_pixel_t color_frame) +void DisplayInfoMessage(const char * const InfoMsg, const std::string& caption, const int& Timeout, const int& Text_mode, fb_pixel_t color_frame) { - ShowMsg(caption, InfoMsg, CMsgBox::mbrBack, CMsgBox::mbOk, NEUTRINO_ICON_INFO, 500, NO_TIMEOUT, false, Text_mode, color_frame); + ShowMsg(caption, InfoMsg, CMsgBox::mbrBack, CMsgBox::mbOk, NEUTRINO_ICON_INFO, 500, Timeout, false, Text_mode, color_frame); } -void DisplayInfoMessage(const char * const InfoMsg, const int& Text_mode, fb_pixel_t color_frame) +void DisplayInfoMessage(const char * const InfoMsg, const int& Timeout, const int& Text_mode, fb_pixel_t color_frame) { - DisplayInfoMessage(InfoMsg, LOCALE_MESSAGEBOX_INFO, Text_mode, color_frame); + DisplayInfoMessage(InfoMsg, LOCALE_MESSAGEBOX_INFO, Timeout, Text_mode, color_frame); } diff --git a/src/gui/widget/msgbox.h b/src/gui/widget/msgbox.h index f15060973..dcca0b8a7 100644 --- a/src/gui/widget/msgbox.h +++ b/src/gui/widget/msgbox.h @@ -403,10 +403,10 @@ int ShowMsg( const std::string & Title, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE, fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8 -void DisplayErrorMessage(const char * const ErrorMsg, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE); // UTF-8 -void DisplayErrorMessage(const char * const ErrorMsg, const neutrino_locale_t& caption, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE); // UTF-8 -void DisplayErrorMessage(const char * const ErrorMsg, const std::string& caption, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE); // UTF-8 -void DisplayInfoMessage(const char * const InfoMsg, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8 -void DisplayInfoMessage(const char * const InfoMsg, const neutrino_locale_t& caption, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8 -void DisplayInfoMessage(const char * const InfoMsg, const std::string& caption, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8 +void DisplayErrorMessage(const char * const ErrorMsg, const int& Timeout = NO_TIMEOUT, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE); // UTF-8 +void DisplayErrorMessage(const char * const ErrorMsg, const neutrino_locale_t& caption, const int& Timeout = NO_TIMEOUT, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE); // UTF-8 +void DisplayErrorMessage(const char * const ErrorMsg, const std::string& caption, const int& Timeout = NO_TIMEOUT, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE); // UTF-8 +void DisplayInfoMessage(const char * const InfoMsg, const int& Timeout = DEFAULT_TIMEOUT, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8 +void DisplayInfoMessage(const char * const InfoMsg, const neutrino_locale_t& caption, const int& Timeout = DEFAULT_TIMEOUT, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8 +void DisplayInfoMessage(const char * const InfoMsg, const std::string& caption, const int& Timeout = DEFAULT_TIMEOUT, const int& Text_mode = DEFAULT_MSGBOX_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8 #endif From b0fb6eeeb79fb6bd088561eda61f1f7268558478 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Wed, 1 Feb 2017 20:38:04 +0100 Subject: [PATCH 18/20] try to fix loop rezap with lua script Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/4fcea5bfd5348ffeb1d3b1bcde4e75352c806cae Author: Jacek Jendrzej Date: 2017-02-01 (Wed, 01 Feb 2017) --- src/zapit/src/zapit.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index c9febc2d4..3d7242db0 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -515,6 +515,11 @@ bool CZapit::ZapIt(const t_channel_id channel_id, bool forupdate, bool startplay if (IS_WEBTV(newchannel->getChannelID()) && !newchannel->getUrl().empty()) { dvbsub_stop(); + if (current_channel->getChannelID() == newchannel->getChannelID() && !newchannel->getScriptName().empty()){ + INFO("[zapit] stop rezap to channel %s id %" PRIx64 ")", newchannel->getName().c_str(), newchannel->getChannelID()); + return true; + } + if (!IS_WEBTV(live_channel_id)) CCamManager::getInstance()->Stop(live_channel_id, CCamManager::PLAY); From 96f53d0b5a69f84e7c791704c080899b122b56d0 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 1 Feb 2017 21:48:05 +0100 Subject: [PATCH 19/20] framebuffer_ng: fix gradient blit fixes https://github.com/neutrino-mp/neutrino-mp/issues/2, thanks satbaby Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/e44146bf731dfb5933943f14459a3cfb754ad1d4 Author: Stefan Seyfried Date: 2017-02-01 (Wed, 01 Feb 2017) --- src/driver/framebuffer_ng.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/driver/framebuffer_ng.cpp b/src/driver/framebuffer_ng.cpp index 283f6066c..5bd27337f 100644 --- a/src/driver/framebuffer_ng.cpp +++ b/src/driver/framebuffer_ng.cpp @@ -589,6 +589,8 @@ fb_pixel_t* CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, co fb_pixel_t *bp = boxBuf; fb_pixel_t *gra = gradientData->gradientBuf; gradientData->boxBuf = boxBuf; + gradientData->x = x; + gradientData->dx = dx; if (gradientData->direction == gradientVertical) { // vertical From b899dea5b2b37237254d451f4cc26c5595a710ee Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 1 Feb 2017 22:07:10 +0100 Subject: [PATCH 20/20] configure.ac: use pkg-config to check freetype version the PKG_CHECK_MODULES macro allows to check for a version -- use it instead of homegrown TUXBOX_APPS_LIB_PKGCONFIG Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/deaab224b91ea3082c0ce93b6748f44f25cfd881 Author: Stefan Seyfried Date: 2017-02-01 (Wed, 01 Feb 2017) --- configure.ac | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 5ce417d76..d0f8034a1 100644 --- a/configure.ac +++ b/configure.ac @@ -98,19 +98,7 @@ AM_CONDITIONAL(USE_TREMOR, test "$TREMOR" = "yes") # TUXBOX_APPS_LIB_PKGCONFIG(OPENSSL,openssl) TUXBOX_APPS_LIB_PKGCONFIG(CURL,libcurl) -TUXBOX_APPS_LIB_PKGCONFIG(FREETYPE,freetype2) -CPPFLAGS+=" $(freetype-config --cflags)" -AC_MSG_CHECKING([whether FreeType version is 2.5.0 or higher]) - AC_TRY_CPP([ - #include - #include FT_FREETYPE_H - #if FREETYPE_MAJOR < 2 || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR < 5) - #error Freetype version too low. - #endif - ], - [AC_MSG_RESULT(yes)], - [AC_MSG_ERROR([Need FreeType library version 2.5.0 or higher]) - ]) +PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 2.5.0], echo "freetype2 >= 2.5.0 found") # fallback to curl-config (which is ugly for cross-compilation) if test -z "$CURL_LIBS" -a -z "$CURL_CFLAGS"; then @@ -119,6 +107,18 @@ fi # fallback to freetype-config (which is ugly for cross-compilation) if test -z "$FREETYPE_LIBS" -a -z "$FREETYPE_CFLAGS"; then TUXBOX_APPS_LIB_CONFIG(FREETYPE,freetype-config) + CPPFLAGS+="$FREETYPE_CFLAGS" + AC_MSG_CHECKING([whether FreeType version is 2.5.0 or higher]) + AC_TRY_CPP([ + #include + #include FT_FREETYPE_H + #if FREETYPE_MAJOR < 2 || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR < 5) + #error Freetype version too low. + #endif + ], + [AC_MSG_RESULT(yes)], + [AC_MSG_ERROR([Need FreeType library version 2.5.0 or higher]) + ]) fi TUXBOX_APPS_LIB_PKGCONFIG(PNG,libpng)