mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 08:51:04 +02:00
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:
@@ -83,10 +83,9 @@
|
||||
|
||||
#if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE
|
||||
#include <hardware/video.h>
|
||||
extern cVideo * videoDecoder;
|
||||
extern cVideo *videoDecoder;
|
||||
#endif
|
||||
|
||||
//NI softupdate
|
||||
#include <sys/stat.h>
|
||||
|
||||
extern int allow_flash;
|
||||
@@ -114,10 +113,9 @@ extern int allow_flash;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int pinghost (const std::string &hostname, std::string *ip = NULL);
|
||||
int pinghost(const std::string &hostname, std::string *ip = NULL);
|
||||
|
||||
CFlashUpdate::CFlashUpdate()
|
||||
:CProgressWindow()
|
||||
CFlashUpdate::CFlashUpdate() : CProgressWindow()
|
||||
{
|
||||
width = 40;
|
||||
setTitle(LOCALE_FLASHUPDATE_HEAD);
|
||||
@@ -129,15 +127,13 @@ CFlashUpdate::CFlashUpdate()
|
||||
gotImage = false; // NOTE: local update can't set gotImage variable!
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CUpdateMenuTarget : public CMenuTarget
|
||||
{
|
||||
int myID;
|
||||
int * myselectedID;
|
||||
int *myselectedID;
|
||||
|
||||
public:
|
||||
CUpdateMenuTarget(const int id, int * const selectedID)
|
||||
public:
|
||||
CUpdateMenuTarget(const int id, int *const selectedID)
|
||||
{
|
||||
myID = id;
|
||||
myselectedID = selectedID;
|
||||
@@ -150,8 +146,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
//NI
|
||||
void CFlashUpdate::update_php(std::string &url, const char* type)
|
||||
void CFlashUpdate::update_php(std::string &url, const char *type)
|
||||
{
|
||||
if (url.find("update.php") != std::string::npos)
|
||||
{
|
||||
@@ -177,7 +172,7 @@ bool CFlashUpdate::checkOnlineVersion()
|
||||
int curVer, newVer;
|
||||
bool newfound = false;
|
||||
|
||||
std::vector<CUpdateMenuTarget*> update_t_list;
|
||||
std::vector<CUpdateMenuTarget *> update_t_list;
|
||||
|
||||
CConfigFile _configfile('\t');
|
||||
std::string versionString = "????????????????";
|
||||
@@ -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,21 +280,19 @@ bool CFlashUpdate::selectHttpImage(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
update_php(url, curInfo.getType()); //NI
|
||||
startpos = url.find('/', startpos+2)+1;
|
||||
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))
|
||||
{
|
||||
std::ifstream in(gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME);
|
||||
bool enabled;
|
||||
CMenuForwarder * mf;
|
||||
CMenuForwarder *mf;
|
||||
while (in >> url >> version >> md5 >> std::ws)
|
||||
{
|
||||
urls.push_back(url);
|
||||
@@ -308,9 +306,9 @@ bool CFlashUpdate::selectHttpImage(void)
|
||||
CFlashVersionInfo versionInfo(versions[i]);
|
||||
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 = 1;
|
||||
if(!allow_flash && (versionInfo.snapshot <= '2'))
|
||||
if (!allow_flash && (versionInfo.snapshot <= '2'))
|
||||
enabled = false;
|
||||
fileTypes[i] = versionInfo.snapshot;
|
||||
std::string description = versionInfo.getType(true);
|
||||
@@ -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();
|
||||
@@ -331,9 +328,9 @@ bool CFlashUpdate::selectHttpImage(void)
|
||||
SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, updates_list));
|
||||
separator = true;
|
||||
}
|
||||
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);
|
||||
//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,9 +344,10 @@ bool CFlashUpdate::selectHttpImage(void)
|
||||
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILEERROR));
|
||||
return false;
|
||||
}
|
||||
if (notify) {
|
||||
if(newfound)
|
||||
ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_NEW_FOUND, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_INFO, MSGBOX_MIN_WIDTH, 6 );
|
||||
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
|
||||
else
|
||||
ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_NEW_NOTFOUND, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_INFO, MSGBOX_MIN_WIDTH, 6);
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -389,33 +388,35 @@ bool CFlashUpdate::selectHttpImage(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFlashUpdate::getUpdateImage(const std::string & version)
|
||||
bool CFlashUpdate::getUpdateImage(const std::string &version)
|
||||
{
|
||||
CHTTPTool httpTool;
|
||||
char const * fname;
|
||||
char const *fname;
|
||||
char dest_name[100];
|
||||
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);
|
||||
|
||||
dprintf(DEBUG_NORMAL, "[update] get update (url): %s - %s\n", filename.c_str(), dest_name);
|
||||
return httpTool.downloadFile(filename, dest_name, 40 );
|
||||
return httpTool.downloadFile(filename, dest_name, 40);
|
||||
}
|
||||
|
||||
bool CFlashUpdate::checkVersion4Update()
|
||||
{
|
||||
char msg[400];
|
||||
CFlashVersionInfo * versionInfo;
|
||||
CFlashVersionInfo *versionInfo;
|
||||
neutrino_locale_t msg_body;
|
||||
dprintf(DEBUG_NORMAL, "[update] mode is %d\n", softupdate_mode);
|
||||
if(softupdate_mode==1) //internet-update
|
||||
if (softupdate_mode == 1) // internet-update
|
||||
{
|
||||
if(!selectHttpImage())
|
||||
if (!selectHttpImage())
|
||||
return false;
|
||||
|
||||
showLocalStatus(100);
|
||||
@@ -428,7 +429,7 @@ bool CFlashUpdate::checkVersion4Update()
|
||||
|
||||
msg_body = LOCALE_FLASHUPDATE_MSGBOX;
|
||||
#ifdef SQUASHFS
|
||||
versionInfo = new CFlashVersionInfo(newVersion);//Memory leak: versionInfo
|
||||
versionInfo = new CFlashVersionInfo(newVersion); // Memory leak: versionInfo
|
||||
sprintf(msg, g_Locale->getText(msg_body), versionInfo->getType(true), versionInfo->getVersionString(), versionInfo->getDate(), versionInfo->getTime());
|
||||
|
||||
if (gotImage)
|
||||
@@ -467,13 +468,14 @@ bool CFlashUpdate::checkVersion4Update()
|
||||
}
|
||||
|
||||
std::string filters[] = {"bin", "txt", "opk", "ipk"};
|
||||
for(size_t i=0; i<sizeof(filters)/sizeof(filters[0]) ;i++)
|
||||
for (size_t i = 0; i < sizeof(filters) / sizeof(filters[0]) ; i++)
|
||||
UpdatesFilter.addFilter(filters[i]);
|
||||
|
||||
UpdatesBrowser.Filter = &UpdatesFilter;
|
||||
|
||||
CFile * file_selected = NULL;
|
||||
if (!(UpdatesBrowser.exec(g_settings.update_dir.c_str()))) {
|
||||
CFile *file_selected = NULL;
|
||||
if (!(UpdatesBrowser.exec(g_settings.update_dir.c_str())))
|
||||
{
|
||||
menu_ret = UpdatesBrowser.getMenuRet();
|
||||
return false;
|
||||
}
|
||||
@@ -485,10 +487,11 @@ bool CFlashUpdate::checkVersion4Update()
|
||||
|
||||
filename = file_selected->Name;
|
||||
|
||||
FILE* fd = fopen(filename.c_str(), "r");
|
||||
if(fd)
|
||||
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));
|
||||
@@ -497,36 +500,40 @@ bool CFlashUpdate::checkVersion4Update()
|
||||
hide();
|
||||
|
||||
#if ENABLE_PKG_MANAGEMENT
|
||||
//package install:
|
||||
if (file_selected->getType() == CFile::FILE_PKG_PACKAGE){
|
||||
// package install:
|
||||
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));
|
||||
}
|
||||
}
|
||||
else
|
||||
DisplayInfoMessage(g_Locale->getText(LOCALE_MESSAGEBOX_FEATURE_NOT_SUPPORTED));
|
||||
//!always leave here!
|
||||
// !always leave here!
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
//set internal filetype
|
||||
char const * ptr = rindex(filename.c_str(), '.');
|
||||
if(ptr) {
|
||||
// set internal filetype
|
||||
char const *ptr = rindex(filename.c_str(), '.');
|
||||
if (ptr)
|
||||
{
|
||||
ptr++;
|
||||
if(!strcmp(ptr, "bin"))
|
||||
if (!strcmp(ptr, "bin"))
|
||||
fileType = 'A';
|
||||
else if(!strcmp(ptr, "txt"))
|
||||
else if (!strcmp(ptr, "txt"))
|
||||
fileType = 'T';
|
||||
else if(!strcmp(ptr, "tgz"))
|
||||
else if (!strcmp(ptr, "tgz"))
|
||||
fileType = 'Z';
|
||||
else if(!strcmp(ptr, "zip"))
|
||||
else if (!strcmp(ptr, "zip"))
|
||||
fileType = 'Z';
|
||||
else if(!allow_flash)
|
||||
else if (!allow_flash)
|
||||
return false;
|
||||
else
|
||||
fileType = 0;
|
||||
@@ -538,7 +545,7 @@ bool CFlashUpdate::checkVersion4Update()
|
||||
return (ShowMsg(LOCALE_MESSAGEBOX_INFO, msg, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) == CMsgBox::mbrYes);
|
||||
}
|
||||
|
||||
int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
int CFlashUpdate::exec(CMenuTarget *parent, const std::string &actionKey)
|
||||
{
|
||||
dprintf(DEBUG_NORMAL, "CFlashUpdate::exec: [%s]\n", actionKey.c_str());
|
||||
if (actionKey == "local")
|
||||
@@ -546,37 +553,39 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
else
|
||||
softupdate_mode = 1;
|
||||
|
||||
if(parent)
|
||||
if (parent)
|
||||
parent->hide();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef VFD_UPDATE
|
||||
CVFD::getInstance()->showProgressBar2(0,"checking",0,"Update Neutrino");
|
||||
CVFD::getInstance()->showProgressBar2(0, "checking", 0, "Update Neutrino");
|
||||
CVFD::getInstance()->setMode(CLCD::MODE_PROGRESSBAR2);
|
||||
#endif // VFD_UPDATE
|
||||
|
||||
|
||||
paint();
|
||||
showGlobalStatus(20);
|
||||
|
||||
if(softupdate_mode==1) //internet-update
|
||||
if (softupdate_mode == 1) // internet-update
|
||||
{
|
||||
char const * fname = rindex(filename.c_str(), '/') +1;
|
||||
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,13 +601,15 @@ 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 ( ShowMsg(LOCALE_MESSAGEBOX_INFO, gotImage ? LOCALE_FLASHUPDATE_INSTALL_IMAGE : LOCALE_FLASHUPDATE_INSTALL_PACKAGE, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) != CMsgBox::mbrYes)
|
||||
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();
|
||||
return menu_return::RETURN_REPAINT;
|
||||
@@ -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;
|
||||
}
|
||||
@@ -634,7 +647,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
return menu_return::RETURN_REPAINT;
|
||||
}
|
||||
|
||||
//status anzeigen
|
||||
// status anzeigen
|
||||
showGlobalStatus(100);
|
||||
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY));
|
||||
hide();
|
||||
@@ -676,7 +689,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
m.addItem(GenericMenuSeparator);
|
||||
CMenuForwarder *mf;
|
||||
|
||||
for (int i = 1; i < 4+1; i++)
|
||||
for (int i = 1; i < 4 + 1; i++)
|
||||
{
|
||||
bool active = !strcmp(c, to_string(i).c_str());
|
||||
bool enable = true;
|
||||
@@ -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);
|
||||
}
|
||||
@@ -737,7 +753,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
#ifndef DRYRUN
|
||||
if (flashing)
|
||||
{
|
||||
if ( FILE *f = fopen("/tmp/.flash.start", "w") )
|
||||
if (FILE *f = fopen("/tmp/.flash.start", "w"))
|
||||
fclose(f);
|
||||
|
||||
CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8);
|
||||
@@ -760,12 +776,13 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
#endif
|
||||
else if (fileType == 'T') // not image, display file contents
|
||||
{
|
||||
FILE* fd = fopen(filename.c_str(), "r");
|
||||
if(fd) {
|
||||
char * buffer;
|
||||
FILE *fd = fopen(filename.c_str(), "r");
|
||||
if (fd)
|
||||
{
|
||||
char *buffer;
|
||||
off_t filesize = lseek(fileno(fd), 0, SEEK_END);
|
||||
lseek(fileno(fd), 0, SEEK_SET);
|
||||
buffer = (char *) malloc((uint32_t)filesize+1);
|
||||
buffer = (char *) malloc((uint32_t)filesize + 1);
|
||||
fread(buffer, (uint32_t)filesize, 1, fd);
|
||||
fclose(fd);
|
||||
buffer[filesize] = 0;
|
||||
@@ -776,7 +793,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
else // not image, install
|
||||
{
|
||||
std::string install_sh = find_executable("install.sh");
|
||||
dprintf(DEBUG_NORMAL, "[update] calling %s %s %s\n", install_sh.c_str(), g_settings.update_dir.c_str(), filename.c_str() );
|
||||
dprintf(DEBUG_NORMAL, "[update] calling %s %s %s\n", install_sh.c_str(), g_settings.update_dir.c_str(), filename.c_str());
|
||||
#ifndef DRYRUN
|
||||
my_system(3, install_sh.c_str(), g_settings.update_dir.c_str(), filename.c_str());
|
||||
#endif
|
||||
@@ -788,7 +805,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
}
|
||||
|
||||
CFlashExpert::CFlashExpert()
|
||||
:CProgressWindow()
|
||||
: CProgressWindow()
|
||||
{
|
||||
selectedMTD = -1;
|
||||
width = 40;
|
||||
@@ -799,10 +816,10 @@ CFlashExpert::CFlashExpert()
|
||||
#endif
|
||||
}
|
||||
|
||||
CFlashExpert* CFlashExpert::getInstance()
|
||||
CFlashExpert *CFlashExpert::getInstance()
|
||||
{
|
||||
static CFlashExpert* FlashExpert = NULL;
|
||||
if(!FlashExpert)
|
||||
static CFlashExpert *FlashExpert = NULL;
|
||||
if (!FlashExpert)
|
||||
FlashExpert = new CFlashExpert();
|
||||
return FlashExpert;
|
||||
}
|
||||
@@ -810,12 +827,14 @@ 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())) {
|
||||
snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_DIRECTORY_NOT_EXIST), 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,9 +843,11 @@ 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)) {
|
||||
snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), "root0");
|
||||
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,8 +860,9 @@ 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)) {
|
||||
snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), path.c_str());
|
||||
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,8 +872,9 @@ 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) {
|
||||
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());
|
||||
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");
|
||||
}
|
||||
@@ -930,7 +965,7 @@ void CFlashExpert::readmtdJFFS2(std::string &filename, std::string title/*=""*/,
|
||||
progress.hide();
|
||||
|
||||
char message[500];
|
||||
snprintf(message, sizeof(message)-1, g_Locale->getText(LOCALE_FLASHUPDATE_SAVESUCCESS), filename.c_str());
|
||||
snprintf(message, sizeof(message) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_SAVESUCCESS), filename.c_str());
|
||||
ShowHint(LOCALE_MESSAGEBOX_INFO, message);
|
||||
}
|
||||
#endif
|
||||
@@ -938,8 +973,8 @@ void CFlashExpert::readmtdJFFS2(std::string &filename, std::string title/*=""*/,
|
||||
void CFlashExpert::readmtd(int preadmtd)
|
||||
{
|
||||
std::string filename;
|
||||
CMTDInfo* mtdInfo = CMTDInfo::getInstance();
|
||||
std::string hostName ="";
|
||||
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
|
||||
std::string hostName = "";
|
||||
netGetHostname(hostName);
|
||||
std::string timeStr = getNowTimeStr("_%Y%m%d_%H%M");
|
||||
std::string tankStr = "";
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1003,13 +1049,16 @@ void CFlashExpert::readmtd(int preadmtd)
|
||||
showGlobalStatus(0);
|
||||
showStatusMessageUTF((std::string(g_Locale->getText(LOCALE_FLASHUPDATE_ACTIONREADFLASH)) + " (" + mtdInfo->getMTDName(preadmtd) + ')'));
|
||||
CFlashTool ft;
|
||||
ft.setStatusViewer( this );
|
||||
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];
|
||||
@@ -1025,7 +1074,7 @@ void CFlashExpert::readmtd(int preadmtd)
|
||||
}
|
||||
}
|
||||
|
||||
void CFlashExpert::writemtd(const std::string & filename, int mtdNumber)
|
||||
void CFlashExpert::writemtd(const std::string &filename, int mtdNumber)
|
||||
{
|
||||
char message[500];
|
||||
|
||||
@@ -1037,7 +1086,7 @@ void CFlashExpert::writemtd(const std::string & filename, int mtdNumber)
|
||||
if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) != CMsgBox::mbrYes)
|
||||
return;
|
||||
#ifdef VFD_UPDATE
|
||||
CVFD::getInstance()->showProgressBar2(0,"checking",0,"Update Neutrino");
|
||||
CVFD::getInstance()->showProgressBar2(0, "checking", 0, "Update Neutrino");
|
||||
CVFD::getInstance()->setMode(CLCD::MODE_PROGRESSBAR2);
|
||||
#endif // VFD_UPDATE
|
||||
|
||||
@@ -1045,12 +1094,15 @@ void CFlashExpert::writemtd(const std::string & filename, int mtdNumber)
|
||||
paint();
|
||||
showGlobalStatus(0);
|
||||
CFlashTool ft;
|
||||
ft.setStatusViewer( this );
|
||||
ft.setMTDDevice( CMTDInfo::getInstance()->getMTDFileName(mtdNumber) );
|
||||
if(!ft.program( (std::string)g_settings.update_dir + "/" + filename, 50, 100)) {
|
||||
ft.setStatusViewer(this);
|
||||
ft.setMTDDevice(CMTDInfo::getInstance()->getMTDFileName(mtdNumber));
|
||||
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);
|
||||
@@ -1060,7 +1112,7 @@ void CFlashExpert::writemtd(const std::string & filename, int mtdNumber)
|
||||
}
|
||||
}
|
||||
|
||||
int CFlashExpert::showMTDSelector(const std::string & actionkey)
|
||||
int CFlashExpert::showMTDSelector(const std::string &actionkey)
|
||||
{
|
||||
int shortcut = 0;
|
||||
|
||||
@@ -1070,12 +1122,13 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey)
|
||||
else if (actionkey == "writemtd")
|
||||
widget_id = MN_WIDGET_ID_MTDWRITE_SELECTOR;
|
||||
|
||||
//generate mtd-selector
|
||||
CMenuWidget* mtdselector = new CMenuWidget(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE, width, widget_id);
|
||||
// generate mtd-selector
|
||||
CMenuWidget *mtdselector = new CMenuWidget(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE, width, widget_id);
|
||||
mtdselector->addIntroItems(LOCALE_FLASHUPDATE_MTDSELECTOR, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
|
||||
|
||||
CMTDInfo* mtdInfo =CMTDInfo::getInstance();
|
||||
for(int lx=0;lx<mtdInfo->getMTDCount();lx++) {
|
||||
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
|
||||
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;
|
||||
@@ -1107,14 +1161,14 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey)
|
||||
mtdselector->addItem(new CMenuForwarder("systemFS with settings", true, NULL, this, "writemtd10", CRCInput::convertDigitToKey(shortcut++)));
|
||||
#endif
|
||||
#endif
|
||||
int res = mtdselector->exec(NULL,"");
|
||||
int res = mtdselector->exec(NULL, "");
|
||||
delete mtdselector;
|
||||
return res;
|
||||
}
|
||||
|
||||
int CFlashExpert::showFileSelector(const std::string & actionkey)
|
||||
int CFlashExpert::showFileSelector(const std::string &actionkey)
|
||||
{
|
||||
CMenuWidget* fileselector = new CMenuWidget(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE, width, MN_WIDGET_ID_FILESELECTOR);
|
||||
CMenuWidget *fileselector = new CMenuWidget(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE, width, MN_WIDGET_ID_FILESELECTOR);
|
||||
fileselector->addIntroItems(LOCALE_FLASHUPDATE_FILESELECTOR, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
|
||||
|
||||
struct dirent **namelist;
|
||||
@@ -1122,71 +1176,84 @@ int CFlashExpert::showFileSelector(const std::string & actionkey)
|
||||
if (n < 0)
|
||||
{
|
||||
perror("no flashimages available");
|
||||
//should be available...
|
||||
// should be available...
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int count=0;count<n;count++)
|
||||
for (int count = 0; count < n; count++)
|
||||
{
|
||||
std::string filen = namelist[count]->d_name;
|
||||
int pos = filen.find(".img");
|
||||
if(pos!=-1)
|
||||
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]);
|
||||
}
|
||||
free(namelist);
|
||||
}
|
||||
int res = fileselector->exec(NULL,"");
|
||||
int res = fileselector->exec(NULL, "");
|
||||
delete fileselector;
|
||||
return res;
|
||||
}
|
||||
|
||||
int CFlashExpert::exec(CMenuTarget* parent, const std::string & actionKey)
|
||||
int CFlashExpert::exec(CMenuTarget *parent, const std::string &actionKey)
|
||||
{
|
||||
int res = menu_return::RETURN_REPAINT;
|
||||
if(parent)
|
||||
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;
|
||||
selectedMTD = -1;
|
||||
}
|
||||
}
|
||||
res = menu_return::RETURN_REPAINT;
|
||||
@@ -1214,25 +1281,28 @@ void CFlashExpertSetup::readMTDPart(int mtd, const std::string &fileName)
|
||||
#define UBOOT_BIN
|
||||
//#define SPARE_BIN
|
||||
|
||||
int CFlashExpertSetup::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
int CFlashExpertSetup::exec(CMenuTarget *parent, const std::string &actionKey)
|
||||
{
|
||||
#define UPDATEDIR "/var/update"
|
||||
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";
|
||||
snprintf(message, sizeof(message)-1, g_Locale->getText(LOCALE_FLASHUPDATE_CREATEIMAGE_WARNING), box, box);
|
||||
snprintf(message, sizeof(message) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_CREATEIMAGE_WARNING), box, box);
|
||||
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)
|
||||
@@ -1296,13 +1366,13 @@ int CFlashExpertSetup::showMenu()
|
||||
CMenuSeparator *s1 = new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_FLASHUPDATE_CREATEIMAGE_OPTIONS);
|
||||
CMenuForwarder *m1 = new CMenuForwarder(LOCALE_FLASHUPDATE_CREATEIMAGE, true, NULL, this, "readmtd0", CRCInput::convertDigitToKey(0));
|
||||
bool isMountVar = (getJFFS2MountPoint(1) == "") ? false : true;
|
||||
CMenuOptionChooser *m8=NULL;
|
||||
CMenuOptionChooser *m8 = NULL;
|
||||
if (isMountVar)
|
||||
m8 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_VAR, &g_settings.flashupdate_createimage_add_var,
|
||||
MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true);
|
||||
|
||||
bool isMountRoot1 = (getJFFS2MountPoint(2) == "") ? false : true;
|
||||
CMenuOptionChooser *m9=NULL;
|
||||
CMenuOptionChooser *m9 = NULL;
|
||||
if (isMountRoot1)
|
||||
m9 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_ROOT1, &g_settings.flashupdate_createimage_add_root1,
|
||||
MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true);
|
||||
@@ -1343,19 +1413,21 @@ 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};
|
||||
snprintf(mText, sizeof(mText)-1, g_Locale->getText(LOCALE_FLASHUPDATE_CREATEIMAGE_OTHER), box);
|
||||
snprintf(mText, sizeof(mText) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_CREATEIMAGE_OTHER), box);
|
||||
CMenuOptionChooser *m7 = new CMenuOptionChooser(mText, &(cfe->createimage_other), MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true);
|
||||
|
||||
rootfsSetup->addItem(GenericMenuSeparatorLine);
|
||||
rootfsSetup->addItem(m7); // create image for other STB
|
||||
} else
|
||||
}
|
||||
else
|
||||
cfe->createimage_other = 0;
|
||||
|
||||
int res = rootfsSetup->exec (NULL, "");
|
||||
int res = rootfsSetup->exec(NULL, "");
|
||||
delete rootfsSetup;
|
||||
|
||||
cfe->createimage_other = 0;
|
||||
|
@@ -30,7 +30,6 @@
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __update__
|
||||
#define __update__
|
||||
|
||||
@@ -60,17 +59,16 @@ 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 getUpdateImage(const std::string &version);
|
||||
bool checkVersion4Update();
|
||||
|
||||
public:
|
||||
CFlashUpdate();
|
||||
int exec( CMenuTarget* parent, const std::string & actionKey );
|
||||
int exec(CMenuTarget *parent, const std::string &actionKey);
|
||||
bool checkOnlineVersion();
|
||||
void enableNotify(bool enable) { notify = enable; }
|
||||
|
||||
};
|
||||
|
||||
class CFlashExpert : public CProgressWindow
|
||||
@@ -79,13 +77,13 @@ class CFlashExpert : public CProgressWindow
|
||||
int selectedMTD;
|
||||
int width;
|
||||
|
||||
int showMTDSelector(const std::string & actionkey);
|
||||
int showFileSelector(const std::string & actionkey);
|
||||
int showMTDSelector(const std::string &actionkey);
|
||||
int showFileSelector(const std::string &actionkey);
|
||||
|
||||
bool checkSize(int mtd, std::string &backupFile);
|
||||
#ifdef BOXMODEL_CST_HD2
|
||||
bool readDevtableFile(std::string &devtableFile, CMkfsJFFS2::v_devtable_t &v_devtable);
|
||||
void readmtdJFFS2(std::string &filename, std::string title="", std::string path="/", bool makeDevTable=true);
|
||||
void readmtdJFFS2(std::string &filename, std::string title = "", std::string path = "/", bool makeDevTable = true);
|
||||
#endif
|
||||
|
||||
public:
|
||||
@@ -95,11 +93,10 @@ class CFlashExpert : public CProgressWindow
|
||||
int createimage_other;
|
||||
#endif
|
||||
CFlashExpert();
|
||||
static CFlashExpert* getInstance();
|
||||
int exec(CMenuTarget* parent, const std::string & actionKey);
|
||||
void writemtd(const std::string & filename, int mtdNumber);
|
||||
static CFlashExpert *getInstance();
|
||||
int exec(CMenuTarget *parent, const std::string &actionKey);
|
||||
void writemtd(const std::string &filename, int mtdNumber);
|
||||
void readmtd(int readmtd);
|
||||
|
||||
};
|
||||
|
||||
#ifdef BOXMODEL_CST_HD2
|
||||
@@ -113,9 +110,9 @@ class CFlashExpertSetup : public CMenuTarget
|
||||
|
||||
public:
|
||||
CFlashExpertSetup();
|
||||
// ~CFlashExpertSetup();
|
||||
//~CFlashExpertSetup();
|
||||
|
||||
int exec(CMenuTarget* parent, const std::string &actionKey);
|
||||
int exec(CMenuTarget *parent, const std::string &actionKey);
|
||||
};
|
||||
#endif // BOXMODEL_CST_HD2
|
||||
|
||||
|
Reference in New Issue
Block a user