- update: smoother view for current image

Conflicts:
	src/gui/update.cpp

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2019-12-31 13:28:21 +01:00
committed by Thilo Graf
parent 085fb5edbe
commit 38dfe21b61

View File

@@ -84,6 +84,9 @@
extern cVideo * videoDecoder; extern cVideo * videoDecoder;
#endif #endif
#if 0 //softupdate
#include <sys/stat.h>
#endif
extern int allow_flash; extern int allow_flash;
//#define DRYRUN //#define DRYRUN
@@ -151,8 +154,12 @@ void CFlashUpdate::update_php(std::string &url, const char* type)
if (url.find("update.php") != std::string::npos) if (url.find("update.php") != std::string::npos)
{ {
url += "?revision=" + to_string(cs_get_revision()); url += "?revision=" + to_string(cs_get_revision());
url += "&boxname=";
url += g_info.hw_caps->boxname;
url += "&chip_type=" + to_string(cs_get_chip_type()); url += "&chip_type=" + to_string(cs_get_chip_type());
url += "&image_type=" + (std::string)type; url += "&image_type=" + (std::string)type;
url = str_replace(" ", "%20", url);
printf("[update_php] url %s\n", url.c_str()); printf("[update_php] url %s\n", url.c_str());
} }
} }
@@ -186,6 +193,7 @@ bool CFlashUpdate::checkOnlineVersion()
std::string host; std::string host;
startpos = url.find("//"); startpos = url.find("//");
if (startpos != std::string::npos) { if (startpos != std::string::npos) {
//update_php(url, curInfo.getType()); //NI
startpos += 2; startpos += 2;
endpos = url.find('/', startpos); endpos = url.find('/', startpos);
host = url.substr(startpos, endpos - startpos); host = url.substr(startpos, endpos - startpos);
@@ -225,8 +233,14 @@ bool CFlashUpdate::selectHttpImage(void)
CConfigFile _configfile('\t'); CConfigFile _configfile('\t');
std::string versionString = "????????????????"; std::string versionString = "????????????????";
if (_configfile.loadConfig("/.version")) std::string imagedescription = "";
std::string imageversion = "n/a";
if (_configfile.loadConfig(TARGET_PREFIX "/.version"))
{
versionString = _configfile.getString("version", "????????????????"); versionString = _configfile.getString("version", "????????????????");
imagedescription = _configfile.getString("imagedescription", "");
imageversion = _configfile.getString("imageversion", "n/a");
}
CFlashVersionInfo curInfo(versionString.c_str()); CFlashVersionInfo curInfo(versionString.c_str());
dprintf(DEBUG_NORMAL, "[update] current flash-version: %s (%d) date %s (%ld)\n", versionString.c_str(), curInfo.getVersion(), curInfo.getDate(), curInfo.getDateTime()); dprintf(DEBUG_NORMAL, "[update] current flash-version: %s (%d) date %s (%ld)\n", versionString.c_str(), curInfo.getVersion(), curInfo.getDate(), curInfo.getDateTime());
@@ -235,17 +249,18 @@ bool CFlashUpdate::selectHttpImage(void)
httpTool.setStatusViewer(this); httpTool.setStatusViewer(this);
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILE)); showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILE));
char current[200]; char currentleft[200];
snprintf(current, 200, "%s %s %s %s", curInfo.getReleaseCycle(), curInfo.getType(true), curInfo.getDate(), curInfo.getTime()); char currentright[200];
snprintf(currentleft, 200, "%s %d - %s, %s", curInfo.getType(true), curInfo.getVersion(), curInfo.getDate(), curInfo.getTime());
snprintf(currentright, 200, "%s %s", imagedescription.c_str(), imageversion.c_str());
CMenuWidget SelectionWidget(LOCALE_FLASHUPDATE_SELECTIMAGE, NEUTRINO_ICON_UPDATE, listWidth, MN_WIDGET_ID_IMAGESELECTOR); CMenuWidget SelectionWidget(LOCALE_FLASHUPDATE_SELECTIMAGE, NEUTRINO_ICON_UPDATE, listWidth, MN_WIDGET_ID_IMAGESELECTOR);
SelectionWidget.addItem(GenericMenuSeparator); SelectionWidget.addItem(GenericMenuSeparator);
SelectionWidget.addItem(GenericMenuBack); SelectionWidget.addItem(GenericMenuBack);
SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::LINE)); SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, g_Locale->getText(LOCALE_FLASHUPDATE_CURRENTVERSION_SEP)));
SelectionWidget.addItem(new CMenuForwarder(currentleft, false, currentright));
SelectionWidget.addItem(new CMenuForwarder(current, false, g_Locale->getText(LOCALE_FLASHUPDATE_CURRENTVERSION_SEP)));
std::ifstream urlFile(g_settings.softupdate_url_file.c_str()); std::ifstream urlFile(g_settings.softupdate_url_file.c_str());
dprintf(DEBUG_NORMAL, "[update] file %s\n", g_settings.softupdate_url_file.c_str()); dprintf(DEBUG_NORMAL, "[update] file %s\n", g_settings.softupdate_url_file.c_str());
@@ -296,12 +311,12 @@ bool CFlashUpdate::selectHttpImage(void)
if(!allow_flash && (versionInfo.snapshot <= '2')) if(!allow_flash && (versionInfo.snapshot <= '2'))
enabled = false; enabled = false;
fileTypes[i] = versionInfo.snapshot; fileTypes[i] = versionInfo.snapshot;
std::string description = versionInfo.getReleaseCycle(); std::string description = versionInfo.getType(true);
description += ' '; description += " ";
description += versionInfo.getType(true); description += versionInfo.getVersion();
description += ' '; description += " - ";
description += versionInfo.getDate(); description += versionInfo.getDate();
description += ' '; description += ", ";
description += versionInfo.getTime(); description += versionInfo.getTime();
descriptions.push_back(description); /* workaround since CMenuForwarder does not store the Option String itself */ descriptions.push_back(description); /* workaround since CMenuForwarder does not store the Option String itself */
@@ -316,7 +331,7 @@ bool CFlashUpdate::selectHttpImage(void)
CUpdateMenuTarget * up = new CUpdateMenuTarget(i, &selected); CUpdateMenuTarget * up = new CUpdateMenuTarget(i, &selected);
mf = new CMenuDForwarder(descriptions[i].c_str(), enabled, names[i].c_str(), up); mf = new CMenuDForwarder(descriptions[i].c_str(), enabled, names[i].c_str(), up);
//TODO mf->setHint(NEUTRINO_ICON_HINT_SW_UPDATE, ""); //TODO mf->setHint(NEUTRINO_ICON_HINT_SW_UPDATE, "");
SelectionWidget.addItem(mf); SelectionWidget.addItem(mf, i == 0); // first entry is preselected
i++; i++;
} }
} }
@@ -349,7 +364,7 @@ bool CFlashUpdate::selectHttpImage(void)
fileType = fileTypes[selected]; fileType = fileTypes[selected];
gotImage = (fileType <= '9'); gotImage = (fileType <= '9');
#ifdef BOXMODEL_CS_HD2 #if 0 //#ifdef BOXMODEL_CS_HD2
if (gotImage) if (gotImage)
{ {
int esize = CMTDInfo::getInstance()->getMTDEraseSize(sysfs); int esize = CMTDInfo::getInstance()->getMTDEraseSize(sysfs);
@@ -359,7 +374,6 @@ bool CFlashUpdate::selectHttpImage(void)
} }
} }
#endif #endif
#if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE #if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE
if (gotImage && (filename.substr(filename.find_last_of(".") + 1) == "tgz" || filename.substr(filename.find_last_of(".") + 1) == "zip")) if (gotImage && (filename.substr(filename.find_last_of(".") + 1) == "tgz" || filename.substr(filename.find_last_of(".") + 1) == "zip"))
{ {
@@ -439,8 +453,8 @@ bool CFlashUpdate::checkVersion4Update()
else else
{ {
CFileBrowser UpdatesBrowser; CFileBrowser UpdatesBrowser;
CFileFilter UpdatesFilter; CFileFilter UpdatesFilter;
if (allow_flash) if (allow_flash)
{ {
UpdatesFilter.addFilter(FILEBROWSER_UPDATE_FILTER); UpdatesFilter.addFilter(FILEBROWSER_UPDATE_FILTER);
@@ -724,7 +738,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
if (restart == CMsgBox::mbrYes) if (restart == CMsgBox::mbrYes)
{ {
if(g_settings.hdmi_cec_standby){ if(g_settings.hdmi_cec_standby){
videoDecoder->SetCECAutoStandby(false); videoDecoder->SetCECMode((VIDEO_HDMI_CEC_MODE)0);
} }
std::string startup_new = "/boot/STARTUP_" + to_string(selected); std::string startup_new = "/boot/STARTUP_" + to_string(selected);
dprintf(DEBUG_NORMAL, "[update] Start selected partition %d (%s)\n", selected, startup_new.c_str()); dprintf(DEBUG_NORMAL, "[update] Start selected partition %d (%s)\n", selected, startup_new.c_str());