update: formatting code using astyle; some manual code nicenings

Origin commit data
------------------
Branch: ni/coolstream
Commit: 79e16c058d
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-12-04 (Sat, 04 Dec 2021)

Origin message was:
------------------
- update: formatting code using astyle; some manual code nicenings

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2021-12-04 23:22:35 +01:00
parent 23ff9fed36
commit c498f78d3b
2 changed files with 322 additions and 253 deletions

View File

@@ -86,7 +86,6 @@
extern cVideo *videoDecoder;
#endif
//NI softupdate
#include <sys/stat.h>
extern int allow_flash;
@@ -116,8 +115,7 @@ extern int allow_flash;
int pinghost(const std::string &hostname, std::string *ip = NULL);
CFlashUpdate::CFlashUpdate()
:CProgressWindow()
CFlashUpdate::CFlashUpdate() : CProgressWindow()
{
width = 40;
setTitle(LOCALE_FLASHUPDATE_HEAD);
@@ -129,8 +127,6 @@ CFlashUpdate::CFlashUpdate()
gotImage = false; // NOTE: local update can't set gotImage variable!
}
class CUpdateMenuTarget : public CMenuTarget
{
int myID;
@@ -150,7 +146,6 @@ public:
}
};
//NI
void CFlashUpdate::update_php(std::string &url, const char *type)
{
if (url.find("update.php") != std::string::npos)
@@ -189,13 +184,15 @@ bool CFlashUpdate::checkOnlineVersion()
dprintf(DEBUG_NORMAL, "[update] current flash-version: %s (%d) date %s (%ld)\n", versionString.c_str(), curInfo.getVersion(), curInfo.getDate(), curInfo.getDateTime());
std::ifstream urlFile(g_settings.softupdate_url_file.c_str());
if (urlFile >> url) {
/* extract domain name */
if (urlFile >> url)
{
// extract domain name
std::string::size_type startpos, endpos;
std::string host;
startpos = url.find("//");
if (startpos != std::string::npos) {
update_php(url, curInfo.getType()); //NI
if (startpos != std::string::npos)
{
update_php(url, curInfo.getType());
startpos += 2;
endpos = url.find('/', startpos);
host = url.substr(startpos, endpos - startpos);
@@ -203,14 +200,17 @@ bool CFlashUpdate::checkOnlineVersion()
dprintf(DEBUG_NORMAL, "[update] host %s\n", host.c_str());
if (host.empty() || (pinghost(host) != 1))
return false;
if (httpTool.downloadFile(url, gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME, 20)) {
if (httpTool.downloadFile(url, gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME, 20))
{
std::ifstream in(gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME);
while (in >> url >> version >> md5 >> std::ws) {
while (in >> url >> version >> md5 >> std::ws)
{
std::getline(in, name);
CFlashVersionInfo versionInfo(version);
newVer = versionInfo.getVersion();
dprintf(DEBUG_NORMAL, "[update] url %s version %s (%d) timestamp %s (%ld) md5 %s name %s\n", url.c_str(), version.c_str(), newVer, versionInfo.getDate(), versionInfo.getDateTime(), md5.c_str(), name.c_str());
if(versionInfo.snapshot <= '2' && (newVer > curVer || versionInfo.getDateTime() > curInfo.getDateTime())) {
if (versionInfo.snapshot <= '2' && (newVer > curVer || versionInfo.getDateTime() > curInfo.getDateTime()))
{
newfound = true;
dprintf(DEBUG_NORMAL, "[update] found new image\n");
break;
@@ -272,7 +272,7 @@ bool CFlashUpdate::selectHttpImage(void)
std::string::size_type startpos, endpos;
dprintf(DEBUG_NORMAL, "[update] url %s\n", url.c_str());
/* extract domain name */
// extract domain name
startpos = url.find("//");
if (startpos == std::string::npos)
{
@@ -280,15 +280,13 @@ bool CFlashUpdate::selectHttpImage(void)
}
else
{
update_php(url, curInfo.getType()); //NI
update_php(url, curInfo.getType());
startpos = url.find('/', startpos + 2) + 1;
}
endpos = std::string::npos;
updates_lists.push_back(url.substr(startpos, endpos - startpos));
//NI don't paint separator for lists with no entry
//NI SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, updates_lists.rbegin()->c_str()));
bool separator = false; //NI
bool separator = false;
if (httpTool.downloadFile(url, gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME, 20))
{
@@ -321,9 +319,8 @@ bool CFlashUpdate::selectHttpImage(void)
description += ", ";
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
//NI
if (!separator)
{
std::string updates_list = updates_lists.rbegin()->c_str();
@@ -333,7 +330,7 @@ bool CFlashUpdate::selectHttpImage(void)
}
CUpdateMenuTarget *up = new CUpdateMenuTarget(i, &selected);
mf = new CMenuDForwarder(descriptions[i].c_str(), enabled, names[i].c_str(), up);
//TODO mf->setHint(NEUTRINO_ICON_HINT_SW_UPDATE, "");
//mf->setHint(NEUTRINO_ICON_HINT_SW_UPDATE, "");
SelectionWidget.addItem(mf, i == 0); // first entry is preselected
i++;
}
@@ -347,7 +344,8 @@ bool CFlashUpdate::selectHttpImage(void)
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILEERROR));
return false;
}
if (notify) {
if (notify)
{
if (newfound)
ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_NEW_FOUND, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_INFO, MSGBOX_MIN_WIDTH, 6);
#if 0
@@ -366,13 +364,14 @@ bool CFlashUpdate::selectHttpImage(void)
file_md5 = md5s[selected];
fileType = fileTypes[selected];
gotImage = (fileType <= '9');
//NI #ifdef BOXMODEL_CST_HD2
//#ifdef BOXMODEL_CST_HD2
#if 0
if (gotImage)
{
int esize = CMTDInfo::getInstance()->getMTDEraseSize(sysfs);
dprintf(DEBUG_NORMAL, "[update] erase size is %x\n", esize);
if (esize == 0x40000) {
if (esize == 0x40000)
{
filename += ".256k";
}
}
@@ -397,8 +396,10 @@ bool CFlashUpdate::getUpdateImage(const std::string & version)
httpTool.setStatusViewer(this);
fname = rindex(filename.c_str(), '/');
if(fname != NULL) fname++;
else return false;
if (fname != NULL)
fname++;
else
return false;
sprintf(dest_name, "%s/%s", g_settings.update_dir.c_str(), fname);
showStatusMessageUTF(std::string(g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILE)) + ' ' + version);
@@ -473,7 +474,8 @@ bool CFlashUpdate::checkVersion4Update()
UpdatesBrowser.Filter = &UpdatesFilter;
CFile *file_selected = NULL;
if (!(UpdatesBrowser.exec(g_settings.update_dir.c_str()))) {
if (!(UpdatesBrowser.exec(g_settings.update_dir.c_str())))
{
menu_ret = UpdatesBrowser.getMenuRet();
return false;
}
@@ -488,7 +490,8 @@ bool CFlashUpdate::checkVersion4Update()
FILE *fd = fopen(filename.c_str(), "r");
if (fd)
fclose(fd);
else {
else
{
hide();
dprintf(DEBUG_NORMAL, "[update] flash/package-file not found: %s\n", filename.c_str());
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE));
@@ -498,11 +501,14 @@ bool CFlashUpdate::checkVersion4Update()
#if ENABLE_PKG_MANAGEMENT
// package install:
if (file_selected->getType() == CFile::FILE_PKG_PACKAGE){
if (file_selected->getType() == CFile::FILE_PKG_PACKAGE)
{
COPKGManager opkg;
if (opkg.hasOpkgSupport()){
if (opkg.hasOpkgSupport())
{
int msgres = ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_OPKG_WARNING_3RDPARTY_PACKAGES, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE, 700);
if (msgres == CMsgBox::mbrYes){
if (msgres == CMsgBox::mbrYes)
{
if (!opkg.installPackage(UpdatesBrowser.getSelectedFile()->Name))
DisplayErrorMessage(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL));
}
@@ -516,7 +522,8 @@ bool CFlashUpdate::checkVersion4Update()
// set internal filetype
char const *ptr = rindex(filename.c_str(), '.');
if(ptr) {
if (ptr)
{
ptr++;
if (!strcmp(ptr, "bin"))
fileType = 'A';
@@ -552,12 +559,14 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
menu_ret = menu_return::RETURN_REPAINT;
paint();
if(sysfs.size() < 8) {
if (sysfs.size() < 8)
{
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENMTD));
hide();
return menu_return::RETURN_REPAINT;
}
if(!checkVersion4Update()) {
if (!checkVersion4Update())
{
hide();
return menu_ret;
}
@@ -567,7 +576,6 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
CVFD::getInstance()->setMode(CLCD::MODE_PROGRESSBAR2);
#endif // VFD_UPDATE
paint();
showGlobalStatus(20);
@@ -576,7 +584,8 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
char const *fname = rindex(filename.c_str(), '/') + 1;
char fullname[255];
if(!getUpdateImage(newVersion)) {
if (!getUpdateImage(newVersion))
{
hide();
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILEERROR));
return menu_return::RETURN_REPAINT;
@@ -592,12 +601,14 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
ft.setStatusViewer(this);
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_MD5CHECK));
if((softupdate_mode==1) && !ft.check_md5(filename, file_md5)) {
if ((softupdate_mode == 1) && !ft.check_md5(filename, file_md5))
{
hide();
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_MD5SUMERROR));
return menu_return::RETURN_REPAINT;
}
if(softupdate_mode==1) { //internet-update
if (softupdate_mode == 1) // internet-update
{
if (ShowMsg(LOCALE_MESSAGEBOX_INFO, gotImage ? LOCALE_FLASHUPDATE_INSTALL_IMAGE : LOCALE_FLASHUPDATE_INSTALL_PACKAGE, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) != CMsgBox::mbrYes)
{
hide();
@@ -613,9 +624,11 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
{
#if ENABLE_EXTUPDATE
#ifndef BOXMODEL_CST_HD2
if (g_settings.apply_settings) {
if (g_settings.apply_settings)
{
if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_APPLY_SETTINGS, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) == CMsgBox::mbrYes)
if (!CExtUpdate::getInstance()->applySettings(filename, CExtUpdate::MODE_SOFTUPDATE)) {
if (!CExtUpdate::getInstance()->applySettings(filename, CExtUpdate::MODE_SOFTUPDATE))
{
hide();
return menu_return::RETURN_REPAINT;
}
@@ -712,7 +725,8 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
restart = ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_SELECTED_PARTITION, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE);
if (restart == CMsgBox::mbrYes)
{
if(g_settings.hdmi_cec_standby){
if (g_settings.hdmi_cec_standby)
{
videoDecoder->SetCECMode((VIDEO_HDMI_CEC_MODE)0);
}
std::string startup_new("/boot/");
@@ -724,7 +738,9 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
fh.copyFile(startup_new.c_str(), "/boot/STARTUP");
#endif
}
} else if (selected > 0 && strcmp(c, to_string(selected).c_str()) == 0) {
}
else if (selected > 0 && strcmp(c, to_string(selected).c_str()) == 0)
{
flashing = true;
ofgwrite_options = "-m" + to_string(selected);
}
@@ -761,7 +777,8 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
else if (fileType == 'T') // not image, display file contents
{
FILE *fd = fopen(filename.c_str(), "r");
if(fd) {
if (fd)
{
char *buffer;
off_t filesize = lseek(fileno(fd), 0, SEEK_END);
lseek(fileno(fd), 0, SEEK_SET);
@@ -810,11 +827,13 @@ CFlashExpert* CFlashExpert::getInstance()
bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
{
#ifndef BOXMODEL_CST_HD2
if (mtd < 0) return false;
if (mtd < 0)
return false;
#endif
char errMsg[1024] = {0};
std::string path = getPathName(backupFile);
if (!file_exists(path.c_str())) {
if (!file_exists(path.c_str()))
{
snprintf(errMsg, sizeof(errMsg) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_DIRECTORY_NOT_EXIST), path.c_str());
DisplayErrorMessage(errMsg);
return false;
@@ -824,8 +843,10 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
long bsize = 0;
uint64_t backupRequiredSize = 0;
#ifdef BOXMODEL_CST_HD2
if (mtd == -1) { // check disk space for image creation
if (!get_fs_usage("/", btotal, bused, &bsize)) {
if (mtd == -1) // check disk space for image creation
{
if (!get_fs_usage("/", btotal, bused, &bsize))
{
snprintf(errMsg, sizeof(errMsg) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), "root0");
DisplayErrorMessage(errMsg);
return false;
@@ -839,7 +860,8 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
backupRequiredSize = CMTDInfo::getInstance()->getMTDSize(mtd) / 1024ULL;
btotal = 0; bused = 0; bsize = 0;
if (!get_fs_usage(path.c_str(), btotal, bused, &bsize)) {
if (!get_fs_usage(path.c_str(), btotal, bused, &bsize))
{
snprintf(errMsg, sizeof(errMsg) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), path.c_str());
DisplayErrorMessage(errMsg);
return false;
@@ -850,7 +872,8 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
dprintf(DEBUG_INFO, "##### [%s] backupMaxSize: %" PRIu64 ", btotal: %" PRIu64 ", bused: %" PRIu64 ", bsize: %ld\n",
__func__, backupMaxSize, btotal, bused, bsize);
if (backupMaxSize < backupRequiredSize) {
if (backupMaxSize < backupRequiredSize)
{
snprintf(errMsg, sizeof(errMsg) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_NO_AVAILABLE_SPACE), path.c_str(), to_string(backupMaxSize).c_str(), to_string(backupRequiredSize).c_str());
DisplayErrorMessage(errMsg);
return false;
@@ -863,33 +886,39 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
bool CFlashExpert::readDevtableFile(std::string &devtableFile, CMkfsJFFS2::v_devtable_t &v_devtable)
{
FILE *fd = fopen(devtableFile.c_str(), "r");
if (!fd) return false;
if (!fd)
return false;
char lineRead[1024];
memset(lineRead, 0, sizeof(lineRead));
bool status = false;
while (fgets(lineRead, sizeof(lineRead)-1, fd)) {
while (fgets(lineRead, sizeof(lineRead) - 1, fd))
{
std::string line = lineRead;
line = trim(line);
// ignore comments
if (line.find_first_of("#") == 0) {
if (line.find_first_of("#") == 0)
{
continue;
}
// ignore comments after the entry
size_t pos = line.find_first_of("#");
if (pos != std::string::npos) {
if (pos != std::string::npos)
{
line = line.substr(0, pos);
line = trim(line);
}
// minimal entry: "/dev/x x 0000"
// length = 13
if (line.length() > 12) {
if (line.length() > 12)
{
v_devtable.push_back(line);
status = true;
}
memset(lineRead, 0, sizeof(lineRead));
}
fclose(fd);
if (!status) return false;
if (!status)
return false;
return true;
}
@@ -905,20 +934,26 @@ void CFlashExpert::readmtdJFFS2(std::string &filename, std::string title/*=""*/,
progress.paint();
int eSize = CMTDInfo::getInstance()->getMTDEraseSize(CMTDInfo::getInstance()->findMTDsystem());
if (createimage_other == 1) {
if (eSize == 0x40000) eSize = 0x20000;
else if (eSize == 0x20000) eSize = 0x40000;
if (createimage_other == 1)
{
if (eSize == 0x40000)
eSize = 0x20000;
else if (eSize == 0x20000)
eSize = 0x40000;
}
CMkfsJFFS2 mkfs;
if (makeDevTable) {
if (makeDevTable)
{
CMkfsJFFS2::v_devtable_t v_devtable;
bool devtableFileIO = false;
std::string devtableFile = (std::string)CONFIGDIR + "/devtable.txt";
if (file_exists(devtableFile.c_str())) {
if (file_exists(devtableFile.c_str()))
{
if (readDevtableFile(devtableFile, v_devtable))
devtableFileIO = true;
}
if (!devtableFileIO || v_devtable.empty()) {
if (!devtableFileIO || v_devtable.empty())
{
v_devtable.push_back("/dev/console c 0600 0 0 5 1 0 0 0");
v_devtable.push_back("/dev/null c 0666 0 0 1 3 0 0 0");
}
@@ -947,14 +982,21 @@ void CFlashExpert::readmtd(int preadmtd)
#if ENABLE_EXTUPDATE
#ifdef BOXMODEL_CST_HD2
int eSize = CMTDInfo::getInstance()->getMTDEraseSize(CMTDInfo::getInstance()->findMTDsystem());
if (preadmtd == 0) {
if (createimage_other == 0) {
if (eSize == 0x40000) tankStr = ".256k";
if (eSize == 0x20000) tankStr = "";
if (preadmtd == 0)
{
if (createimage_other == 0)
{
if (eSize == 0x40000)
tankStr = ".256k";
if (eSize == 0x20000)
tankStr = "";
}
else if (createimage_other == 1) {
if (eSize == 0x40000) tankStr = "";
if (eSize == 0x20000) tankStr = ".256k";
else if (createimage_other == 1)
{
if (eSize == 0x40000)
tankStr = "";
if (eSize == 0x20000)
tankStr = ".256k";
}
}
#endif
@@ -967,22 +1009,26 @@ void CFlashExpert::readmtd(int preadmtd)
#ifdef BOXMODEL_CST_HD2
std::string title = " (" + CMTDInfo::getInstance()->getMTDName(preadmtd) + ")";
std::string mountp = getJFFS2MountPoint(preadmtd);
if (preadmtd == 0) {
if (preadmtd == 0)
{
readmtdJFFS2(filename, title);
return;
}
if (preadmtd == 1) {
if (preadmtd == 1)
{
if (mountp != "")
readmtdJFFS2(filename, title, mountp.c_str(), false);
return;
}
if (preadmtd == 2) {
if (preadmtd == 2)
{
if (mountp != "")
readmtdJFFS2(filename, title, mountp.c_str(), false);
return;
}
#endif
if (preadmtd == -1) {
if (preadmtd == -1)
{
filename = (std::string)g_settings.update_dir + "/flashimage.img"; // US-ASCII (subset of UTF-8 and ISO8859-1)
preadmtd = MTD_OF_WHOLE_IMAGE;
}
@@ -1006,10 +1052,13 @@ void CFlashExpert::readmtd(int preadmtd)
ft.setStatusViewer(this);
ft.setMTDDevice(mtdInfo->getMTDFileName(preadmtd));
if(!ft.readFromMTD(filename, 100)) {
if (!ft.readFromMTD(filename, 100))
{
showStatusMessageUTF(ft.getErrorMessage());
sleep(10);
} else {
}
else
{
showGlobalStatus(100);
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY));
char message[500];
@@ -1047,10 +1096,13 @@ void CFlashExpert::writemtd(const std::string & filename, int mtdNumber)
CFlashTool ft;
ft.setStatusViewer(this);
ft.setMTDDevice(CMTDInfo::getInstance()->getMTDFileName(mtdNumber));
if(!ft.program( (std::string)g_settings.update_dir + "/" + filename, 50, 100)) {
if (!ft.program((std::string)g_settings.update_dir + "/" + filename, 50, 100))
{
showStatusMessageUTF(ft.getErrorMessage());
sleep(10);
} else {
}
else
{
showGlobalStatus(100);
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY));
sleep(2);
@@ -1075,7 +1127,8 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey)
mtdselector->addIntroItems(LOCALE_FLASHUPDATE_MTDSELECTOR, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
for(int lx=0;lx<mtdInfo->getMTDCount();lx++) {
for (int lx = 0; lx < mtdInfo->getMTDCount(); lx++)
{
char sActionKey[20];
bool enabled = true;
#ifdef BOXMODEL_CST_HD2
@@ -1084,7 +1137,8 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey)
lx == mtdInfo->findMTDNumberFromName("uldr") ||
lx == mtdInfo->findMTDNumberFromName("env")))
enabled = false;
if (actionkey == "readmtd") {
if (actionkey == "readmtd")
{
// Enabled when file system is mounted
if (lx == mtdInfo->findMTDNumberFromName("var"))
enabled = (getJFFS2MountPoint(lx) == "") ? false : true;
@@ -1133,7 +1187,7 @@ int CFlashExpert::showFileSelector(const std::string & actionkey)
if (pos != -1)
{
fileselector->addItem(new CMenuForwarder(filen.c_str(), true, NULL, this, (actionkey + filen).c_str()));
//TODO make sure filen is UTF-8 encoded
// TODO: make sure filen is UTF-8 encoded
}
free(namelist[count]);
}
@@ -1150,41 +1204,54 @@ int CFlashExpert::exec(CMenuTarget* parent, const std::string & actionKey)
if (parent)
parent->hide();
if(actionKey=="readflash") {
if (actionKey == "readflash")
{
readmtd(-1);
}
else if(actionKey=="writeflash") {
else if (actionKey == "writeflash")
{
res = showFileSelector("");
}
else if(actionKey=="readflashmtd") {
else if (actionKey == "readflashmtd")
{
res = showMTDSelector("readmtd");
}
else if(actionKey=="writeflashmtd") {
else if (actionKey == "writeflashmtd")
{
res = showMTDSelector("writemtd");
}
else {
else
{
int iReadmtd = -1;
int iWritemtd = -1;
sscanf(actionKey.c_str(), "readmtd%d", &iReadmtd);
sscanf(actionKey.c_str(), "writemtd%d", &iWritemtd);
if(iReadmtd!=-1) {
if (iReadmtd != -1)
{
readmtd(iReadmtd);
}
else if(iWritemtd!=-1) {
else if (iWritemtd != -1)
{
dprintf(DEBUG_NORMAL, "[update] mtd-write\n\n");
selectedMTD = iWritemtd;
showFileSelector("");
} else {
}
else
{
#if ENABLE_EXTUPDATE
if(selectedMTD == 10) {
if (selectedMTD == 10)
{
std::string aK = actionKey;
CExtUpdate::getInstance()->applySettings(aK, CExtUpdate::MODE_EXPERT);
}
else
#endif
if (selectedMTD == -1) {
if (selectedMTD == -1)
{
writemtd(actionKey, MTD_OF_WHOLE_IMAGE);
} else {
}
else
{
writemtd(actionKey, selectedMTD);
selectedMTD = -1;
}
@@ -1220,11 +1287,13 @@ int CFlashExpertSetup::exec(CMenuTarget* parent, const std::string &actionKey)
if (parent)
parent->hide();
if (actionKey == "readmtd0") {
if (actionKey == "readmtd0")
{
CFlashExpert *cfe = CFlashExpert::getInstance();
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
bool skipImage = false;
if (cfe->createimage_other == 1) {
if (cfe->createimage_other == 1)
{
char message[512] = {0};
// create image warning
const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank";
@@ -1232,7 +1301,8 @@ int CFlashExpertSetup::exec(CMenuTarget* parent, const std::string &actionKey)
if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE, 600) != CMsgBox::mbrYes)
skipImage = true;
}
if (!skipImage) {
if (!skipImage)
{
std::string uldrName = (std::string)UPDATEDIR + "/uldr.bin";
cfe->forceOtherFilename = true;
if (g_settings.flashupdate_createimage_add_uldr == 1)
@@ -1343,7 +1413,8 @@ int CFlashExpertSetup::showMenu()
#endif
rootfsSetup->addItem(m6); // include kernel
if (cs_get_revision() != 12) { // not kronos
if (cs_get_revision() != 12) // not kronos
{
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank";
char mText[512] = {0};
@@ -1352,7 +1423,8 @@ int CFlashExpertSetup::showMenu()
rootfsSetup->addItem(GenericMenuSeparatorLine);
rootfsSetup->addItem(m7); // create image for other STB
} else
}
else
cfe->createimage_other = 0;
int res = rootfsSetup->exec(NULL, "");

View File

@@ -30,7 +30,6 @@
Boston, MA 02110-1301, USA.
*/
#ifndef __update__
#define __update__
@@ -60,7 +59,7 @@ class CFlashUpdate : public CProgressWindow
int menu_ret;
int softupdate_mode;
void update_php(std::string &url, const char* type); //NI
void update_php(std::string &url, const char *type);
bool selectHttpImage(void);
bool getUpdateImage(const std::string &version);
bool checkVersion4Update();
@@ -70,7 +69,6 @@ class CFlashUpdate : public CProgressWindow
int exec(CMenuTarget *parent, const std::string &actionKey);
bool checkOnlineVersion();
void enableNotify(bool enable) { notify = enable; }
};
class CFlashExpert : public CProgressWindow
@@ -99,7 +97,6 @@ class CFlashExpert : public CProgressWindow
int exec(CMenuTarget *parent, const std::string &actionKey);
void writemtd(const std::string &filename, int mtdNumber);
void readmtd(int readmtd);
};
#ifdef BOXMODEL_CST_HD2