From 311f1857fae771d2d4e5ffa50e4c52eb1f130d7d Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 29 Nov 2018 22:47:42 +0100 Subject: [PATCH] update: fix release cycle handling; add human readable version string Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/87d60639aea60cdc5b17466a159f693fe7893d7f Author: vanhofen Date: 2018-11-29 (Thu, 29 Nov 2018) Origin message was: ------------------ - update: fix release cycle handling; add human readable version string --- data/locale/deutsch.locale | 2 +- data/locale/english.locale | 2 +- src/gui/imageinfo.cpp | 2 +- src/gui/imageinfo_ni.cpp | 4 ++-- src/gui/update.cpp | 20 +++++++------------- src/system/flashtool.cpp | 31 +++++++++++++++++-------------- src/system/flashtool.h | 6 ++++-- 7 files changed, 33 insertions(+), 34 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 50ef6bb1e..91485b083 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -731,7 +731,7 @@ flashupdate.menu_apply_settings Settingsübernahme erlauben flashupdate.mkfs_create_image Backup erstellen flashupdate.mkfs_preparing_files Dateien und Verzeichnisse vorbereiten flashupdate.mkfs_using_sumtool Benutze Sumtool -flashupdate.msgbox Es wurde folgende neue Datei gefunden:\nDatum: %s, %s\nBasis-Image: %s\nTyp: %s\n\nWollen Sie diese Version jetzt herunterladen? +flashupdate.msgbox Es wurde folgendes Update gefunden:\n%s %s vom %s, %s\n\nWollen Sie diese Version jetzt herunterladen? flashupdate.mtdselector Partitions-Auswahl flashupdate.namemode1 Dateiname Settingsfile flashupdate.namemode1_default +settings.img diff --git a/data/locale/english.locale b/data/locale/english.locale index 2255dec2f..e2960a6e9 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -731,7 +731,7 @@ flashupdate.menu_apply_settings Allow apply settings flashupdate.mkfs_create_image Create backup flashupdate.mkfs_preparing_files Preparing files and directories flashupdate.mkfs_using_sumtool Using sumtool -flashupdate.msgbox Found the following new file:\nDate: %s, %s\nBaseImage: %s\nType: %s\n\nDo you want to download this version now? +flashupdate.msgbox Found the following update:\n%s %s of %s, %s\n\nDo you want to download this version now? flashupdate.mtdselector Partition-Selector flashupdate.namemode1 Filename settingsfile flashupdate.namemode1_default +settings.img diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp index 7f67a7680..aa636eca5 100644 --- a/src/gui/imageinfo.cpp +++ b/src/gui/imageinfo.cpp @@ -299,7 +299,7 @@ void CImageInfo::InitInfoData() } if (is_version_code && version_string.size() == 16){ static CFlashVersionInfo versionInfo(version_string.c_str()); - version_string = versionInfo.getReleaseCycle(); + version_string = versionInfo.getVersionString(); version_string += " "; version_string += versionInfo.getType(); version_string += " ("; diff --git a/src/gui/imageinfo_ni.cpp b/src/gui/imageinfo_ni.cpp index 0ec262de5..dec650219 100644 --- a/src/gui/imageinfo_ni.cpp +++ b/src/gui/imageinfo_ni.cpp @@ -298,9 +298,9 @@ void CImageInfoNI::paint() if (version.compare("n/a") != 0) { static CFlashVersionInfo versionInfo(version); - std::string releaseCycle = versionInfo.getReleaseCycle(); + std::string v = versionInfo.getVersionString(); imageversion.str(""); - imageversion << releaseCycle << " (" << versionInfo.getType(true) << ")"; + imageversion << v << " (" << versionInfo.getType(true) << ")"; } #endif diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 1fac6f3b8..2a9ab650d 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -238,13 +238,7 @@ bool CFlashUpdate::selectHttpImage(void) showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILE)); char current[200]; -#if 0 - snprintf(current, 200, "%s: %s %s %s %s %s", g_Locale->getText(LOCALE_FLASHUPDATE_CURRENTVERSION_SEP), curInfo.getReleaseCycle(), - g_Locale->getText(LOCALE_FLASHUPDATE_CURRENTVERSIONDATE), curInfo.getDate(), - g_Locale->getText(LOCALE_FLASHUPDATE_CURRENTVERSIONTIME), curInfo.getTime()); -#endif - //NI - snprintf(current, 200, "%s %s %s %s", curInfo.getReleaseCycle(), curInfo.getType(true), curInfo.getDate(), curInfo.getTime()); + snprintf(current, 200, "%s %s - %s, %s", curInfo.getType(true), curInfo.getVersionString(), curInfo.getDate(), curInfo.getTime()); CMenuWidget SelectionWidget(LOCALE_FLASHUPDATE_SELECTIMAGE, NEUTRINO_ICON_UPDATE, listWidth, MN_WIDGET_ID_IMAGESELECTOR); @@ -303,12 +297,12 @@ bool CFlashUpdate::selectHttpImage(void) if(!allow_flash && (versionInfo.snapshot <= '2')) enabled = false; fileTypes[i] = versionInfo.snapshot; - std::string description = versionInfo.getReleaseCycle(); - description += ' '; - description += versionInfo.getType(true); - description += ' '; + std::string description = versionInfo.getType(true); + description += " "; + description += versionInfo.getVersionString(); + description += " - "; description += versionInfo.getDate(); - description += ' '; + description += ", "; description += versionInfo.getTime(); descriptions.push_back(description); /* workaround since CMenuForwarder does not store the Option String itself */ @@ -417,7 +411,7 @@ bool CFlashUpdate::checkVersion4Update() msg_body = LOCALE_FLASHUPDATE_MSGBOX; #ifdef SQUASHFS versionInfo = new CFlashVersionInfo(newVersion);//Memory leak: versionInfo - sprintf(msg, g_Locale->getText(msg_body), versionInfo->getDate(), versionInfo->getTime(), versionInfo->getReleaseCycle(), versionInfo->getType(true)); + sprintf(msg, g_Locale->getText(msg_body), versionInfo->getType(true), versionInfo->getVersionString(), versionInfo->getDate(), versionInfo->getTime()); if (fileType <= '2') { diff --git a/src/system/flashtool.cpp b/src/system/flashtool.cpp index 65a7ba4e9..641ac6235 100644 --- a/src/system/flashtool.cpp +++ b/src/system/flashtool.cpp @@ -481,23 +481,21 @@ CFlashVersionInfo::CFlashVersionInfo(const std::string & _versionString) snapshot = versionString[0]; // recover release cycle version + // will be compared with RELEASE_CYCLE, which is defined in configure.ac as "x.0" releaseCycle[0] = versionString[1]; releaseCycle[1] = '.'; -/* - if (versionString[2] == '0') - { - releaseCycle[2] = versionString[3]; - releaseCycle[3] = 0; - } - else -*/ - { - releaseCycle[2] = versionString[2]; - releaseCycle[3] = versionString[3]; - releaseCycle[4] = 0; - } + releaseCycle[2] = '0'; + releaseCycle[3] = 0; + + // human readable version + vstring[0] = versionString[1]; + vstring[1] = '.'; + vstring[2] = versionString[2]; + vstring[3] = versionString[3]; + vstring[4] = 0; + + version = atoi(&versionString[1])*100 + atoi(&versionString[2])*10 + atoi(&versionString[3]); - version = atoi(&releaseCycle[0]) * 100 + atoi(&releaseCycle[2]); // recover date struct tm tt; memset(&tt, 0, sizeof(tt)); @@ -579,6 +577,11 @@ int CFlashVersionInfo::getVersion(void) const return version; } +const char *CFlashVersionInfo::getVersionString(void) const +{ + return vstring; +} + //----------------------------------------------------------------------------------------------------------------- CMTDInfo::CMTDInfo() diff --git a/src/system/flashtool.h b/src/system/flashtool.h index 50e5cd344..96bd83475 100644 --- a/src/system/flashtool.h +++ b/src/system/flashtool.h @@ -80,7 +80,8 @@ class CFlashVersionInfo char date[11]; char time[6]; - char releaseCycle[5]; + char releaseCycle[4]; + char vstring[5]; // human readable version int version; time_t datetime; @@ -93,7 +94,8 @@ class CFlashVersionInfo const char *getTime(void) const; const char *getReleaseCycle(void) const; const char *getType(bool localized = false) const; - int getVersion(void) const; + int getVersion(void) const; + const char *getVersionString(void) const; time_t getDateTime(void) const { return datetime; }; };