mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 17:01:08 +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
|
#if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE
|
||||||
#include <hardware/video.h>
|
#include <hardware/video.h>
|
||||||
extern cVideo * videoDecoder;
|
extern cVideo *videoDecoder;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//NI softupdate
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
extern int allow_flash;
|
extern int allow_flash;
|
||||||
@@ -114,10 +113,9 @@ extern int allow_flash;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int pinghost (const std::string &hostname, std::string *ip = NULL);
|
int pinghost(const std::string &hostname, std::string *ip = NULL);
|
||||||
|
|
||||||
CFlashUpdate::CFlashUpdate()
|
CFlashUpdate::CFlashUpdate() : CProgressWindow()
|
||||||
:CProgressWindow()
|
|
||||||
{
|
{
|
||||||
width = 40;
|
width = 40;
|
||||||
setTitle(LOCALE_FLASHUPDATE_HEAD);
|
setTitle(LOCALE_FLASHUPDATE_HEAD);
|
||||||
@@ -129,15 +127,13 @@ CFlashUpdate::CFlashUpdate()
|
|||||||
gotImage = false; // NOTE: local update can't set gotImage variable!
|
gotImage = false; // NOTE: local update can't set gotImage variable!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CUpdateMenuTarget : public CMenuTarget
|
class CUpdateMenuTarget : public CMenuTarget
|
||||||
{
|
{
|
||||||
int myID;
|
int myID;
|
||||||
int * myselectedID;
|
int *myselectedID;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CUpdateMenuTarget(const int id, int * const selectedID)
|
CUpdateMenuTarget(const int id, int *const selectedID)
|
||||||
{
|
{
|
||||||
myID = id;
|
myID = id;
|
||||||
myselectedID = selectedID;
|
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)
|
if (url.find("update.php") != std::string::npos)
|
||||||
{
|
{
|
||||||
@@ -177,7 +172,7 @@ bool CFlashUpdate::checkOnlineVersion()
|
|||||||
int curVer, newVer;
|
int curVer, newVer;
|
||||||
bool newfound = false;
|
bool newfound = false;
|
||||||
|
|
||||||
std::vector<CUpdateMenuTarget*> update_t_list;
|
std::vector<CUpdateMenuTarget *> update_t_list;
|
||||||
|
|
||||||
CConfigFile _configfile('\t');
|
CConfigFile _configfile('\t');
|
||||||
std::string versionString = "????????????????";
|
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());
|
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());
|
std::ifstream urlFile(g_settings.softupdate_url_file.c_str());
|
||||||
if (urlFile >> url) {
|
if (urlFile >> url)
|
||||||
/* extract domain name */
|
{
|
||||||
|
// extract domain name
|
||||||
std::string::size_type startpos, endpos;
|
std::string::size_type startpos, endpos;
|
||||||
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
|
{
|
||||||
|
update_php(url, curInfo.getType());
|
||||||
startpos += 2;
|
startpos += 2;
|
||||||
endpos = url.find('/', startpos);
|
endpos = url.find('/', startpos);
|
||||||
host = url.substr(startpos, endpos - startpos);
|
host = url.substr(startpos, endpos - startpos);
|
||||||
@@ -203,14 +200,17 @@ bool CFlashUpdate::checkOnlineVersion()
|
|||||||
dprintf(DEBUG_NORMAL, "[update] host %s\n", host.c_str());
|
dprintf(DEBUG_NORMAL, "[update] host %s\n", host.c_str());
|
||||||
if (host.empty() || (pinghost(host) != 1))
|
if (host.empty() || (pinghost(host) != 1))
|
||||||
return false;
|
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);
|
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);
|
std::getline(in, name);
|
||||||
CFlashVersionInfo versionInfo(version);
|
CFlashVersionInfo versionInfo(version);
|
||||||
newVer = versionInfo.getVersion();
|
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());
|
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;
|
newfound = true;
|
||||||
dprintf(DEBUG_NORMAL, "[update] found new image\n");
|
dprintf(DEBUG_NORMAL, "[update] found new image\n");
|
||||||
break;
|
break;
|
||||||
@@ -272,7 +272,7 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
std::string::size_type startpos, endpos;
|
std::string::size_type startpos, endpos;
|
||||||
dprintf(DEBUG_NORMAL, "[update] url %s\n", url.c_str());
|
dprintf(DEBUG_NORMAL, "[update] url %s\n", url.c_str());
|
||||||
|
|
||||||
/* extract domain name */
|
// extract domain name
|
||||||
startpos = url.find("//");
|
startpos = url.find("//");
|
||||||
if (startpos == std::string::npos)
|
if (startpos == std::string::npos)
|
||||||
{
|
{
|
||||||
@@ -280,21 +280,19 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
update_php(url, curInfo.getType()); //NI
|
update_php(url, curInfo.getType());
|
||||||
startpos = url.find('/', startpos+2)+1;
|
startpos = url.find('/', startpos + 2) + 1;
|
||||||
}
|
}
|
||||||
endpos = std::string::npos;
|
endpos = std::string::npos;
|
||||||
updates_lists.push_back(url.substr(startpos, endpos - startpos));
|
updates_lists.push_back(url.substr(startpos, endpos - startpos));
|
||||||
|
|
||||||
//NI don't paint separator for lists with no entry
|
bool separator = false;
|
||||||
//NI SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, updates_lists.rbegin()->c_str()));
|
|
||||||
bool separator = false; //NI
|
|
||||||
|
|
||||||
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);
|
std::ifstream in(gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME);
|
||||||
bool enabled;
|
bool enabled;
|
||||||
CMenuForwarder * mf;
|
CMenuForwarder *mf;
|
||||||
while (in >> url >> version >> md5 >> std::ws)
|
while (in >> url >> version >> md5 >> std::ws)
|
||||||
{
|
{
|
||||||
urls.push_back(url);
|
urls.push_back(url);
|
||||||
@@ -308,9 +306,9 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
CFlashVersionInfo versionInfo(versions[i]);
|
CFlashVersionInfo versionInfo(versions[i]);
|
||||||
newVer = versionInfo.getVersion();
|
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());
|
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;
|
newfound = 1;
|
||||||
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.getType(true);
|
std::string description = versionInfo.getType(true);
|
||||||
@@ -321,9 +319,8 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
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
|
||||||
|
|
||||||
//NI
|
|
||||||
if (!separator)
|
if (!separator)
|
||||||
{
|
{
|
||||||
std::string updates_list = updates_lists.rbegin()->c_str();
|
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));
|
SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, updates_list));
|
||||||
separator = true;
|
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);
|
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
|
SelectionWidget.addItem(mf, i == 0); // first entry is preselected
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -347,9 +344,10 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILEERROR));
|
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILEERROR));
|
||||||
return false;
|
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 (newfound)
|
||||||
|
ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_NEW_FOUND, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_INFO, MSGBOX_MIN_WIDTH, 6);
|
||||||
#if 0
|
#if 0
|
||||||
else
|
else
|
||||||
ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_NEW_NOTFOUND, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_INFO, MSGBOX_MIN_WIDTH, 6);
|
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];
|
file_md5 = md5s[selected];
|
||||||
fileType = fileTypes[selected];
|
fileType = fileTypes[selected];
|
||||||
gotImage = (fileType <= '9');
|
gotImage = (fileType <= '9');
|
||||||
//NI #ifdef BOXMODEL_CST_HD2
|
//#ifdef BOXMODEL_CST_HD2
|
||||||
#if 0
|
#if 0
|
||||||
if (gotImage)
|
if (gotImage)
|
||||||
{
|
{
|
||||||
int esize = CMTDInfo::getInstance()->getMTDEraseSize(sysfs);
|
int esize = CMTDInfo::getInstance()->getMTDEraseSize(sysfs);
|
||||||
dprintf(DEBUG_NORMAL, "[update] erase size is %x\n", esize);
|
dprintf(DEBUG_NORMAL, "[update] erase size is %x\n", esize);
|
||||||
if (esize == 0x40000) {
|
if (esize == 0x40000)
|
||||||
|
{
|
||||||
filename += ".256k";
|
filename += ".256k";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -389,33 +388,35 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CFlashUpdate::getUpdateImage(const std::string & version)
|
bool CFlashUpdate::getUpdateImage(const std::string &version)
|
||||||
{
|
{
|
||||||
CHTTPTool httpTool;
|
CHTTPTool httpTool;
|
||||||
char const * fname;
|
char const *fname;
|
||||||
char dest_name[100];
|
char dest_name[100];
|
||||||
httpTool.setStatusViewer(this);
|
httpTool.setStatusViewer(this);
|
||||||
|
|
||||||
fname = rindex(filename.c_str(), '/');
|
fname = rindex(filename.c_str(), '/');
|
||||||
if(fname != NULL) fname++;
|
if (fname != NULL)
|
||||||
else return false;
|
fname++;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
sprintf(dest_name, "%s/%s", g_settings.update_dir.c_str(), fname);
|
sprintf(dest_name, "%s/%s", g_settings.update_dir.c_str(), fname);
|
||||||
showStatusMessageUTF(std::string(g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILE)) + ' ' + version);
|
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);
|
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()
|
bool CFlashUpdate::checkVersion4Update()
|
||||||
{
|
{
|
||||||
char msg[400];
|
char msg[400];
|
||||||
CFlashVersionInfo * versionInfo;
|
CFlashVersionInfo *versionInfo;
|
||||||
neutrino_locale_t msg_body;
|
neutrino_locale_t msg_body;
|
||||||
dprintf(DEBUG_NORMAL, "[update] mode is %d\n", softupdate_mode);
|
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;
|
return false;
|
||||||
|
|
||||||
showLocalStatus(100);
|
showLocalStatus(100);
|
||||||
@@ -428,7 +429,7 @@ bool CFlashUpdate::checkVersion4Update()
|
|||||||
|
|
||||||
msg_body = LOCALE_FLASHUPDATE_MSGBOX;
|
msg_body = LOCALE_FLASHUPDATE_MSGBOX;
|
||||||
#ifdef SQUASHFS
|
#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());
|
sprintf(msg, g_Locale->getText(msg_body), versionInfo->getType(true), versionInfo->getVersionString(), versionInfo->getDate(), versionInfo->getTime());
|
||||||
|
|
||||||
if (gotImage)
|
if (gotImage)
|
||||||
@@ -467,13 +468,14 @@ bool CFlashUpdate::checkVersion4Update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string filters[] = {"bin", "txt", "opk", "ipk"};
|
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]);
|
UpdatesFilter.addFilter(filters[i]);
|
||||||
|
|
||||||
UpdatesBrowser.Filter = &UpdatesFilter;
|
UpdatesBrowser.Filter = &UpdatesFilter;
|
||||||
|
|
||||||
CFile * file_selected = NULL;
|
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();
|
menu_ret = UpdatesBrowser.getMenuRet();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -485,10 +487,11 @@ bool CFlashUpdate::checkVersion4Update()
|
|||||||
|
|
||||||
filename = file_selected->Name;
|
filename = file_selected->Name;
|
||||||
|
|
||||||
FILE* fd = fopen(filename.c_str(), "r");
|
FILE *fd = fopen(filename.c_str(), "r");
|
||||||
if(fd)
|
if (fd)
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
hide();
|
hide();
|
||||||
dprintf(DEBUG_NORMAL, "[update] flash/package-file not found: %s\n", filename.c_str());
|
dprintf(DEBUG_NORMAL, "[update] flash/package-file not found: %s\n", filename.c_str());
|
||||||
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE));
|
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE));
|
||||||
@@ -497,36 +500,40 @@ bool CFlashUpdate::checkVersion4Update()
|
|||||||
hide();
|
hide();
|
||||||
|
|
||||||
#if ENABLE_PKG_MANAGEMENT
|
#if ENABLE_PKG_MANAGEMENT
|
||||||
//package install:
|
// package install:
|
||||||
if (file_selected->getType() == CFile::FILE_PKG_PACKAGE){
|
if (file_selected->getType() == CFile::FILE_PKG_PACKAGE)
|
||||||
|
{
|
||||||
COPKGManager opkg;
|
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);
|
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))
|
if (!opkg.installPackage(UpdatesBrowser.getSelectedFile()->Name))
|
||||||
DisplayErrorMessage(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL));
|
DisplayErrorMessage(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DisplayInfoMessage(g_Locale->getText(LOCALE_MESSAGEBOX_FEATURE_NOT_SUPPORTED));
|
DisplayInfoMessage(g_Locale->getText(LOCALE_MESSAGEBOX_FEATURE_NOT_SUPPORTED));
|
||||||
//!always leave here!
|
// !always leave here!
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//set internal filetype
|
// set internal filetype
|
||||||
char const * ptr = rindex(filename.c_str(), '.');
|
char const *ptr = rindex(filename.c_str(), '.');
|
||||||
if(ptr) {
|
if (ptr)
|
||||||
|
{
|
||||||
ptr++;
|
ptr++;
|
||||||
if(!strcmp(ptr, "bin"))
|
if (!strcmp(ptr, "bin"))
|
||||||
fileType = 'A';
|
fileType = 'A';
|
||||||
else if(!strcmp(ptr, "txt"))
|
else if (!strcmp(ptr, "txt"))
|
||||||
fileType = 'T';
|
fileType = 'T';
|
||||||
else if(!strcmp(ptr, "tgz"))
|
else if (!strcmp(ptr, "tgz"))
|
||||||
fileType = 'Z';
|
fileType = 'Z';
|
||||||
else if(!strcmp(ptr, "zip"))
|
else if (!strcmp(ptr, "zip"))
|
||||||
fileType = 'Z';
|
fileType = 'Z';
|
||||||
else if(!allow_flash)
|
else if (!allow_flash)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
fileType = 0;
|
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);
|
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());
|
dprintf(DEBUG_NORMAL, "CFlashUpdate::exec: [%s]\n", actionKey.c_str());
|
||||||
if (actionKey == "local")
|
if (actionKey == "local")
|
||||||
@@ -546,37 +553,39 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
else
|
else
|
||||||
softupdate_mode = 1;
|
softupdate_mode = 1;
|
||||||
|
|
||||||
if(parent)
|
if (parent)
|
||||||
parent->hide();
|
parent->hide();
|
||||||
|
|
||||||
menu_ret = menu_return::RETURN_REPAINT;
|
menu_ret = menu_return::RETURN_REPAINT;
|
||||||
paint();
|
paint();
|
||||||
|
|
||||||
if(sysfs.size() < 8) {
|
if (sysfs.size() < 8)
|
||||||
|
{
|
||||||
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENMTD));
|
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENMTD));
|
||||||
hide();
|
hide();
|
||||||
return menu_return::RETURN_REPAINT;
|
return menu_return::RETURN_REPAINT;
|
||||||
}
|
}
|
||||||
if(!checkVersion4Update()) {
|
if (!checkVersion4Update())
|
||||||
|
{
|
||||||
hide();
|
hide();
|
||||||
return menu_ret;
|
return menu_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VFD_UPDATE
|
#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);
|
CVFD::getInstance()->setMode(CLCD::MODE_PROGRESSBAR2);
|
||||||
#endif // VFD_UPDATE
|
#endif // VFD_UPDATE
|
||||||
|
|
||||||
|
|
||||||
paint();
|
paint();
|
||||||
showGlobalStatus(20);
|
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];
|
char fullname[255];
|
||||||
|
|
||||||
if(!getUpdateImage(newVersion)) {
|
if (!getUpdateImage(newVersion))
|
||||||
|
{
|
||||||
hide();
|
hide();
|
||||||
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILEERROR));
|
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILEERROR));
|
||||||
return menu_return::RETURN_REPAINT;
|
return menu_return::RETURN_REPAINT;
|
||||||
@@ -592,13 +601,15 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
ft.setStatusViewer(this);
|
ft.setStatusViewer(this);
|
||||||
|
|
||||||
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_MD5CHECK));
|
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();
|
hide();
|
||||||
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_MD5SUMERROR));
|
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_MD5SUMERROR));
|
||||||
return menu_return::RETURN_REPAINT;
|
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)
|
{
|
||||||
|
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();
|
hide();
|
||||||
return menu_return::RETURN_REPAINT;
|
return menu_return::RETURN_REPAINT;
|
||||||
@@ -613,9 +624,11 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
{
|
{
|
||||||
#if ENABLE_EXTUPDATE
|
#if ENABLE_EXTUPDATE
|
||||||
#ifndef BOXMODEL_CST_HD2
|
#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 (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();
|
hide();
|
||||||
return menu_return::RETURN_REPAINT;
|
return menu_return::RETURN_REPAINT;
|
||||||
}
|
}
|
||||||
@@ -634,7 +647,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
return menu_return::RETURN_REPAINT;
|
return menu_return::RETURN_REPAINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
//status anzeigen
|
// status anzeigen
|
||||||
showGlobalStatus(100);
|
showGlobalStatus(100);
|
||||||
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY));
|
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY));
|
||||||
hide();
|
hide();
|
||||||
@@ -676,7 +689,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
m.addItem(GenericMenuSeparator);
|
m.addItem(GenericMenuSeparator);
|
||||||
CMenuForwarder *mf;
|
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 active = !strcmp(c, to_string(i).c_str());
|
||||||
bool enable = true;
|
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);
|
restart = ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_SELECTED_PARTITION, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE);
|
||||||
if (restart == CMsgBox::mbrYes)
|
if (restart == CMsgBox::mbrYes)
|
||||||
{
|
{
|
||||||
if(g_settings.hdmi_cec_standby){
|
if (g_settings.hdmi_cec_standby)
|
||||||
|
{
|
||||||
videoDecoder->SetCECMode((VIDEO_HDMI_CEC_MODE)0);
|
videoDecoder->SetCECMode((VIDEO_HDMI_CEC_MODE)0);
|
||||||
}
|
}
|
||||||
std::string startup_new("/boot/");
|
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");
|
fh.copyFile(startup_new.c_str(), "/boot/STARTUP");
|
||||||
#endif
|
#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;
|
flashing = true;
|
||||||
ofgwrite_options = "-m" + to_string(selected);
|
ofgwrite_options = "-m" + to_string(selected);
|
||||||
}
|
}
|
||||||
@@ -737,7 +753,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
#ifndef DRYRUN
|
#ifndef DRYRUN
|
||||||
if (flashing)
|
if (flashing)
|
||||||
{
|
{
|
||||||
if ( FILE *f = fopen("/tmp/.flash.start", "w") )
|
if (FILE *f = fopen("/tmp/.flash.start", "w"))
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8);
|
CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8);
|
||||||
@@ -760,12 +776,13 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
#endif
|
#endif
|
||||||
else if (fileType == 'T') // not image, display file contents
|
else if (fileType == 'T') // not image, display file contents
|
||||||
{
|
{
|
||||||
FILE* fd = fopen(filename.c_str(), "r");
|
FILE *fd = fopen(filename.c_str(), "r");
|
||||||
if(fd) {
|
if (fd)
|
||||||
char * buffer;
|
{
|
||||||
|
char *buffer;
|
||||||
off_t filesize = lseek(fileno(fd), 0, SEEK_END);
|
off_t filesize = lseek(fileno(fd), 0, SEEK_END);
|
||||||
lseek(fileno(fd), 0, SEEK_SET);
|
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);
|
fread(buffer, (uint32_t)filesize, 1, fd);
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
buffer[filesize] = 0;
|
buffer[filesize] = 0;
|
||||||
@@ -776,7 +793,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
else // not image, install
|
else // not image, install
|
||||||
{
|
{
|
||||||
std::string install_sh = find_executable("install.sh");
|
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
|
#ifndef DRYRUN
|
||||||
my_system(3, install_sh.c_str(), g_settings.update_dir.c_str(), filename.c_str());
|
my_system(3, install_sh.c_str(), g_settings.update_dir.c_str(), filename.c_str());
|
||||||
#endif
|
#endif
|
||||||
@@ -788,7 +805,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CFlashExpert::CFlashExpert()
|
CFlashExpert::CFlashExpert()
|
||||||
:CProgressWindow()
|
: CProgressWindow()
|
||||||
{
|
{
|
||||||
selectedMTD = -1;
|
selectedMTD = -1;
|
||||||
width = 40;
|
width = 40;
|
||||||
@@ -799,10 +816,10 @@ CFlashExpert::CFlashExpert()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CFlashExpert* CFlashExpert::getInstance()
|
CFlashExpert *CFlashExpert::getInstance()
|
||||||
{
|
{
|
||||||
static CFlashExpert* FlashExpert = NULL;
|
static CFlashExpert *FlashExpert = NULL;
|
||||||
if(!FlashExpert)
|
if (!FlashExpert)
|
||||||
FlashExpert = new CFlashExpert();
|
FlashExpert = new CFlashExpert();
|
||||||
return FlashExpert;
|
return FlashExpert;
|
||||||
}
|
}
|
||||||
@@ -810,12 +827,14 @@ CFlashExpert* CFlashExpert::getInstance()
|
|||||||
bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
|
bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
|
||||||
{
|
{
|
||||||
#ifndef BOXMODEL_CST_HD2
|
#ifndef BOXMODEL_CST_HD2
|
||||||
if (mtd < 0) return false;
|
if (mtd < 0)
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
char errMsg[1024] = {0};
|
char errMsg[1024] = {0};
|
||||||
std::string path = getPathName(backupFile);
|
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());
|
{
|
||||||
|
snprintf(errMsg, sizeof(errMsg) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_DIRECTORY_NOT_EXIST), path.c_str());
|
||||||
DisplayErrorMessage(errMsg);
|
DisplayErrorMessage(errMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -824,9 +843,11 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
|
|||||||
long bsize = 0;
|
long bsize = 0;
|
||||||
uint64_t backupRequiredSize = 0;
|
uint64_t backupRequiredSize = 0;
|
||||||
#ifdef BOXMODEL_CST_HD2
|
#ifdef BOXMODEL_CST_HD2
|
||||||
if (mtd == -1) { // check disk space for image creation
|
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 (!get_fs_usage("/", btotal, bused, &bsize))
|
||||||
|
{
|
||||||
|
snprintf(errMsg, sizeof(errMsg) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), "root0");
|
||||||
DisplayErrorMessage(errMsg);
|
DisplayErrorMessage(errMsg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -839,8 +860,9 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
|
|||||||
backupRequiredSize = CMTDInfo::getInstance()->getMTDSize(mtd) / 1024ULL;
|
backupRequiredSize = CMTDInfo::getInstance()->getMTDSize(mtd) / 1024ULL;
|
||||||
|
|
||||||
btotal = 0; bused = 0; bsize = 0;
|
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());
|
{
|
||||||
|
snprintf(errMsg, sizeof(errMsg) - 1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), path.c_str());
|
||||||
DisplayErrorMessage(errMsg);
|
DisplayErrorMessage(errMsg);
|
||||||
return false;
|
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",
|
dprintf(DEBUG_INFO, "##### [%s] backupMaxSize: %" PRIu64 ", btotal: %" PRIu64 ", bused: %" PRIu64 ", bsize: %ld\n",
|
||||||
__func__, backupMaxSize, btotal, bused, bsize);
|
__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());
|
{
|
||||||
|
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);
|
DisplayErrorMessage(errMsg);
|
||||||
return false;
|
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)
|
bool CFlashExpert::readDevtableFile(std::string &devtableFile, CMkfsJFFS2::v_devtable_t &v_devtable)
|
||||||
{
|
{
|
||||||
FILE *fd = fopen(devtableFile.c_str(), "r");
|
FILE *fd = fopen(devtableFile.c_str(), "r");
|
||||||
if (!fd) return false;
|
if (!fd)
|
||||||
|
return false;
|
||||||
char lineRead[1024];
|
char lineRead[1024];
|
||||||
memset(lineRead, 0, sizeof(lineRead));
|
memset(lineRead, 0, sizeof(lineRead));
|
||||||
bool status = false;
|
bool status = false;
|
||||||
while (fgets(lineRead, sizeof(lineRead)-1, fd)) {
|
while (fgets(lineRead, sizeof(lineRead) - 1, fd))
|
||||||
|
{
|
||||||
std::string line = lineRead;
|
std::string line = lineRead;
|
||||||
line = trim(line);
|
line = trim(line);
|
||||||
// ignore comments
|
// ignore comments
|
||||||
if (line.find_first_of("#") == 0) {
|
if (line.find_first_of("#") == 0)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// ignore comments after the entry
|
// ignore comments after the entry
|
||||||
size_t pos = line.find_first_of("#");
|
size_t pos = line.find_first_of("#");
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
line = line.substr(0, pos);
|
line = line.substr(0, pos);
|
||||||
line = trim(line);
|
line = trim(line);
|
||||||
}
|
}
|
||||||
// minimal entry: "/dev/x x 0000"
|
// minimal entry: "/dev/x x 0000"
|
||||||
// length = 13
|
// length = 13
|
||||||
if (line.length() > 12) {
|
if (line.length() > 12)
|
||||||
|
{
|
||||||
v_devtable.push_back(line);
|
v_devtable.push_back(line);
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
memset(lineRead, 0, sizeof(lineRead));
|
memset(lineRead, 0, sizeof(lineRead));
|
||||||
}
|
}
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
if (!status) return false;
|
if (!status)
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -905,20 +934,26 @@ void CFlashExpert::readmtdJFFS2(std::string &filename, std::string title/*=""*/,
|
|||||||
progress.paint();
|
progress.paint();
|
||||||
|
|
||||||
int eSize = CMTDInfo::getInstance()->getMTDEraseSize(CMTDInfo::getInstance()->findMTDsystem());
|
int eSize = CMTDInfo::getInstance()->getMTDEraseSize(CMTDInfo::getInstance()->findMTDsystem());
|
||||||
if (createimage_other == 1) {
|
if (createimage_other == 1)
|
||||||
if (eSize == 0x40000) eSize = 0x20000;
|
{
|
||||||
else if (eSize == 0x20000) eSize = 0x40000;
|
if (eSize == 0x40000)
|
||||||
|
eSize = 0x20000;
|
||||||
|
else if (eSize == 0x20000)
|
||||||
|
eSize = 0x40000;
|
||||||
}
|
}
|
||||||
CMkfsJFFS2 mkfs;
|
CMkfsJFFS2 mkfs;
|
||||||
if (makeDevTable) {
|
if (makeDevTable)
|
||||||
|
{
|
||||||
CMkfsJFFS2::v_devtable_t v_devtable;
|
CMkfsJFFS2::v_devtable_t v_devtable;
|
||||||
bool devtableFileIO = false;
|
bool devtableFileIO = false;
|
||||||
std::string devtableFile = (std::string)CONFIGDIR + "/devtable.txt";
|
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))
|
if (readDevtableFile(devtableFile, v_devtable))
|
||||||
devtableFileIO = true;
|
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/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");
|
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();
|
progress.hide();
|
||||||
|
|
||||||
char message[500];
|
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);
|
ShowHint(LOCALE_MESSAGEBOX_INFO, message);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -938,8 +973,8 @@ void CFlashExpert::readmtdJFFS2(std::string &filename, std::string title/*=""*/,
|
|||||||
void CFlashExpert::readmtd(int preadmtd)
|
void CFlashExpert::readmtd(int preadmtd)
|
||||||
{
|
{
|
||||||
std::string filename;
|
std::string filename;
|
||||||
CMTDInfo* mtdInfo = CMTDInfo::getInstance();
|
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
|
||||||
std::string hostName ="";
|
std::string hostName = "";
|
||||||
netGetHostname(hostName);
|
netGetHostname(hostName);
|
||||||
std::string timeStr = getNowTimeStr("_%Y%m%d_%H%M");
|
std::string timeStr = getNowTimeStr("_%Y%m%d_%H%M");
|
||||||
std::string tankStr = "";
|
std::string tankStr = "";
|
||||||
@@ -947,14 +982,21 @@ void CFlashExpert::readmtd(int preadmtd)
|
|||||||
#if ENABLE_EXTUPDATE
|
#if ENABLE_EXTUPDATE
|
||||||
#ifdef BOXMODEL_CST_HD2
|
#ifdef BOXMODEL_CST_HD2
|
||||||
int eSize = CMTDInfo::getInstance()->getMTDEraseSize(CMTDInfo::getInstance()->findMTDsystem());
|
int eSize = CMTDInfo::getInstance()->getMTDEraseSize(CMTDInfo::getInstance()->findMTDsystem());
|
||||||
if (preadmtd == 0) {
|
if (preadmtd == 0)
|
||||||
if (createimage_other == 0) {
|
{
|
||||||
if (eSize == 0x40000) tankStr = ".256k";
|
if (createimage_other == 0)
|
||||||
if (eSize == 0x20000) tankStr = "";
|
{
|
||||||
|
if (eSize == 0x40000)
|
||||||
|
tankStr = ".256k";
|
||||||
|
if (eSize == 0x20000)
|
||||||
|
tankStr = "";
|
||||||
}
|
}
|
||||||
else if (createimage_other == 1) {
|
else if (createimage_other == 1)
|
||||||
if (eSize == 0x40000) tankStr = "";
|
{
|
||||||
if (eSize == 0x20000) tankStr = ".256k";
|
if (eSize == 0x40000)
|
||||||
|
tankStr = "";
|
||||||
|
if (eSize == 0x20000)
|
||||||
|
tankStr = ".256k";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -967,22 +1009,26 @@ void CFlashExpert::readmtd(int preadmtd)
|
|||||||
#ifdef BOXMODEL_CST_HD2
|
#ifdef BOXMODEL_CST_HD2
|
||||||
std::string title = " (" + CMTDInfo::getInstance()->getMTDName(preadmtd) + ")";
|
std::string title = " (" + CMTDInfo::getInstance()->getMTDName(preadmtd) + ")";
|
||||||
std::string mountp = getJFFS2MountPoint(preadmtd);
|
std::string mountp = getJFFS2MountPoint(preadmtd);
|
||||||
if (preadmtd == 0) {
|
if (preadmtd == 0)
|
||||||
|
{
|
||||||
readmtdJFFS2(filename, title);
|
readmtdJFFS2(filename, title);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (preadmtd == 1) {
|
if (preadmtd == 1)
|
||||||
|
{
|
||||||
if (mountp != "")
|
if (mountp != "")
|
||||||
readmtdJFFS2(filename, title, mountp.c_str(), false);
|
readmtdJFFS2(filename, title, mountp.c_str(), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (preadmtd == 2) {
|
if (preadmtd == 2)
|
||||||
|
{
|
||||||
if (mountp != "")
|
if (mountp != "")
|
||||||
readmtdJFFS2(filename, title, mountp.c_str(), false);
|
readmtdJFFS2(filename, title, mountp.c_str(), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
filename = (std::string)g_settings.update_dir + "/flashimage.img"; // US-ASCII (subset of UTF-8 and ISO8859-1)
|
||||||
preadmtd = MTD_OF_WHOLE_IMAGE;
|
preadmtd = MTD_OF_WHOLE_IMAGE;
|
||||||
}
|
}
|
||||||
@@ -1003,13 +1049,16 @@ void CFlashExpert::readmtd(int preadmtd)
|
|||||||
showGlobalStatus(0);
|
showGlobalStatus(0);
|
||||||
showStatusMessageUTF((std::string(g_Locale->getText(LOCALE_FLASHUPDATE_ACTIONREADFLASH)) + " (" + mtdInfo->getMTDName(preadmtd) + ')'));
|
showStatusMessageUTF((std::string(g_Locale->getText(LOCALE_FLASHUPDATE_ACTIONREADFLASH)) + " (" + mtdInfo->getMTDName(preadmtd) + ')'));
|
||||||
CFlashTool ft;
|
CFlashTool ft;
|
||||||
ft.setStatusViewer( this );
|
ft.setStatusViewer(this);
|
||||||
ft.setMTDDevice(mtdInfo->getMTDFileName(preadmtd));
|
ft.setMTDDevice(mtdInfo->getMTDFileName(preadmtd));
|
||||||
|
|
||||||
if(!ft.readFromMTD(filename, 100)) {
|
if (!ft.readFromMTD(filename, 100))
|
||||||
|
{
|
||||||
showStatusMessageUTF(ft.getErrorMessage());
|
showStatusMessageUTF(ft.getErrorMessage());
|
||||||
sleep(10);
|
sleep(10);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
showGlobalStatus(100);
|
showGlobalStatus(100);
|
||||||
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY));
|
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY));
|
||||||
char message[500];
|
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];
|
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)
|
if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) != CMsgBox::mbrYes)
|
||||||
return;
|
return;
|
||||||
#ifdef VFD_UPDATE
|
#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);
|
CVFD::getInstance()->setMode(CLCD::MODE_PROGRESSBAR2);
|
||||||
#endif // VFD_UPDATE
|
#endif // VFD_UPDATE
|
||||||
|
|
||||||
@@ -1045,12 +1094,15 @@ void CFlashExpert::writemtd(const std::string & filename, int mtdNumber)
|
|||||||
paint();
|
paint();
|
||||||
showGlobalStatus(0);
|
showGlobalStatus(0);
|
||||||
CFlashTool ft;
|
CFlashTool ft;
|
||||||
ft.setStatusViewer( this );
|
ft.setStatusViewer(this);
|
||||||
ft.setMTDDevice( CMTDInfo::getInstance()->getMTDFileName(mtdNumber) );
|
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());
|
showStatusMessageUTF(ft.getErrorMessage());
|
||||||
sleep(10);
|
sleep(10);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
showGlobalStatus(100);
|
showGlobalStatus(100);
|
||||||
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY));
|
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY));
|
||||||
sleep(2);
|
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;
|
int shortcut = 0;
|
||||||
|
|
||||||
@@ -1070,12 +1122,13 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey)
|
|||||||
else if (actionkey == "writemtd")
|
else if (actionkey == "writemtd")
|
||||||
widget_id = MN_WIDGET_ID_MTDWRITE_SELECTOR;
|
widget_id = MN_WIDGET_ID_MTDWRITE_SELECTOR;
|
||||||
|
|
||||||
//generate mtd-selector
|
// generate mtd-selector
|
||||||
CMenuWidget* mtdselector = new CMenuWidget(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE, width, widget_id);
|
CMenuWidget *mtdselector = new CMenuWidget(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE, width, widget_id);
|
||||||
mtdselector->addIntroItems(LOCALE_FLASHUPDATE_MTDSELECTOR, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
|
mtdselector->addIntroItems(LOCALE_FLASHUPDATE_MTDSELECTOR, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
|
||||||
|
|
||||||
CMTDInfo* mtdInfo =CMTDInfo::getInstance();
|
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
|
||||||
for(int lx=0;lx<mtdInfo->getMTDCount();lx++) {
|
for (int lx = 0; lx < mtdInfo->getMTDCount(); lx++)
|
||||||
|
{
|
||||||
char sActionKey[20];
|
char sActionKey[20];
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
#ifdef BOXMODEL_CST_HD2
|
#ifdef BOXMODEL_CST_HD2
|
||||||
@@ -1084,7 +1137,8 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey)
|
|||||||
lx == mtdInfo->findMTDNumberFromName("uldr") ||
|
lx == mtdInfo->findMTDNumberFromName("uldr") ||
|
||||||
lx == mtdInfo->findMTDNumberFromName("env")))
|
lx == mtdInfo->findMTDNumberFromName("env")))
|
||||||
enabled = false;
|
enabled = false;
|
||||||
if (actionkey == "readmtd") {
|
if (actionkey == "readmtd")
|
||||||
|
{
|
||||||
// Enabled when file system is mounted
|
// Enabled when file system is mounted
|
||||||
if (lx == mtdInfo->findMTDNumberFromName("var"))
|
if (lx == mtdInfo->findMTDNumberFromName("var"))
|
||||||
enabled = (getJFFS2MountPoint(lx) == "") ? false : true;
|
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++)));
|
mtdselector->addItem(new CMenuForwarder("systemFS with settings", true, NULL, this, "writemtd10", CRCInput::convertDigitToKey(shortcut++)));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
int res = mtdselector->exec(NULL,"");
|
int res = mtdselector->exec(NULL, "");
|
||||||
delete mtdselector;
|
delete mtdselector;
|
||||||
return res;
|
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);
|
fileselector->addIntroItems(LOCALE_FLASHUPDATE_FILESELECTOR, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
|
||||||
|
|
||||||
struct dirent **namelist;
|
struct dirent **namelist;
|
||||||
@@ -1122,71 +1176,84 @@ int CFlashExpert::showFileSelector(const std::string & actionkey)
|
|||||||
if (n < 0)
|
if (n < 0)
|
||||||
{
|
{
|
||||||
perror("no flashimages available");
|
perror("no flashimages available");
|
||||||
//should be available...
|
// should be available...
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(int count=0;count<n;count++)
|
for (int count = 0; count < n; count++)
|
||||||
{
|
{
|
||||||
std::string filen = namelist[count]->d_name;
|
std::string filen = namelist[count]->d_name;
|
||||||
int pos = filen.find(".img");
|
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()));
|
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[count]);
|
||||||
}
|
}
|
||||||
free(namelist);
|
free(namelist);
|
||||||
}
|
}
|
||||||
int res = fileselector->exec(NULL,"");
|
int res = fileselector->exec(NULL, "");
|
||||||
delete fileselector;
|
delete fileselector;
|
||||||
return res;
|
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;
|
int res = menu_return::RETURN_REPAINT;
|
||||||
if(parent)
|
if (parent)
|
||||||
parent->hide();
|
parent->hide();
|
||||||
|
|
||||||
if(actionKey=="readflash") {
|
if (actionKey == "readflash")
|
||||||
|
{
|
||||||
readmtd(-1);
|
readmtd(-1);
|
||||||
}
|
}
|
||||||
else if(actionKey=="writeflash") {
|
else if (actionKey == "writeflash")
|
||||||
|
{
|
||||||
res = showFileSelector("");
|
res = showFileSelector("");
|
||||||
}
|
}
|
||||||
else if(actionKey=="readflashmtd") {
|
else if (actionKey == "readflashmtd")
|
||||||
|
{
|
||||||
res = showMTDSelector("readmtd");
|
res = showMTDSelector("readmtd");
|
||||||
}
|
}
|
||||||
else if(actionKey=="writeflashmtd") {
|
else if (actionKey == "writeflashmtd")
|
||||||
|
{
|
||||||
res = showMTDSelector("writemtd");
|
res = showMTDSelector("writemtd");
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
int iReadmtd = -1;
|
int iReadmtd = -1;
|
||||||
int iWritemtd = -1;
|
int iWritemtd = -1;
|
||||||
sscanf(actionKey.c_str(), "readmtd%d", &iReadmtd);
|
sscanf(actionKey.c_str(), "readmtd%d", &iReadmtd);
|
||||||
sscanf(actionKey.c_str(), "writemtd%d", &iWritemtd);
|
sscanf(actionKey.c_str(), "writemtd%d", &iWritemtd);
|
||||||
if(iReadmtd!=-1) {
|
if (iReadmtd != -1)
|
||||||
|
{
|
||||||
readmtd(iReadmtd);
|
readmtd(iReadmtd);
|
||||||
}
|
}
|
||||||
else if(iWritemtd!=-1) {
|
else if (iWritemtd != -1)
|
||||||
|
{
|
||||||
dprintf(DEBUG_NORMAL, "[update] mtd-write\n\n");
|
dprintf(DEBUG_NORMAL, "[update] mtd-write\n\n");
|
||||||
selectedMTD = iWritemtd;
|
selectedMTD = iWritemtd;
|
||||||
showFileSelector("");
|
showFileSelector("");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
#if ENABLE_EXTUPDATE
|
#if ENABLE_EXTUPDATE
|
||||||
if(selectedMTD == 10) {
|
if (selectedMTD == 10)
|
||||||
|
{
|
||||||
std::string aK = actionKey;
|
std::string aK = actionKey;
|
||||||
CExtUpdate::getInstance()->applySettings(aK, CExtUpdate::MODE_EXPERT);
|
CExtUpdate::getInstance()->applySettings(aK, CExtUpdate::MODE_EXPERT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (selectedMTD == -1) {
|
if (selectedMTD == -1)
|
||||||
|
{
|
||||||
writemtd(actionKey, MTD_OF_WHOLE_IMAGE);
|
writemtd(actionKey, MTD_OF_WHOLE_IMAGE);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
writemtd(actionKey, selectedMTD);
|
writemtd(actionKey, selectedMTD);
|
||||||
selectedMTD=-1;
|
selectedMTD = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = menu_return::RETURN_REPAINT;
|
res = menu_return::RETURN_REPAINT;
|
||||||
@@ -1214,25 +1281,28 @@ void CFlashExpertSetup::readMTDPart(int mtd, const std::string &fileName)
|
|||||||
#define UBOOT_BIN
|
#define UBOOT_BIN
|
||||||
//#define SPARE_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"
|
#define UPDATEDIR "/var/update"
|
||||||
if (parent)
|
if (parent)
|
||||||
parent->hide();
|
parent->hide();
|
||||||
|
|
||||||
if (actionKey == "readmtd0") {
|
if (actionKey == "readmtd0")
|
||||||
|
{
|
||||||
CFlashExpert *cfe = CFlashExpert::getInstance();
|
CFlashExpert *cfe = CFlashExpert::getInstance();
|
||||||
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
|
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
|
||||||
bool skipImage = false;
|
bool skipImage = false;
|
||||||
if (cfe->createimage_other == 1) {
|
if (cfe->createimage_other == 1)
|
||||||
|
{
|
||||||
char message[512] = {0};
|
char message[512] = {0};
|
||||||
// create image warning
|
// create image warning
|
||||||
const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank";
|
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)
|
if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE, 600) != CMsgBox::mbrYes)
|
||||||
skipImage = true;
|
skipImage = true;
|
||||||
}
|
}
|
||||||
if (!skipImage) {
|
if (!skipImage)
|
||||||
|
{
|
||||||
std::string uldrName = (std::string)UPDATEDIR + "/uldr.bin";
|
std::string uldrName = (std::string)UPDATEDIR + "/uldr.bin";
|
||||||
cfe->forceOtherFilename = true;
|
cfe->forceOtherFilename = true;
|
||||||
if (g_settings.flashupdate_createimage_add_uldr == 1)
|
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);
|
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));
|
CMenuForwarder *m1 = new CMenuForwarder(LOCALE_FLASHUPDATE_CREATEIMAGE, true, NULL, this, "readmtd0", CRCInput::convertDigitToKey(0));
|
||||||
bool isMountVar = (getJFFS2MountPoint(1) == "") ? false : true;
|
bool isMountVar = (getJFFS2MountPoint(1) == "") ? false : true;
|
||||||
CMenuOptionChooser *m8=NULL;
|
CMenuOptionChooser *m8 = NULL;
|
||||||
if (isMountVar)
|
if (isMountVar)
|
||||||
m8 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_VAR, &g_settings.flashupdate_createimage_add_var,
|
m8 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_VAR, &g_settings.flashupdate_createimage_add_var,
|
||||||
MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true);
|
MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true);
|
||||||
|
|
||||||
bool isMountRoot1 = (getJFFS2MountPoint(2) == "") ? false : true;
|
bool isMountRoot1 = (getJFFS2MountPoint(2) == "") ? false : true;
|
||||||
CMenuOptionChooser *m9=NULL;
|
CMenuOptionChooser *m9 = NULL;
|
||||||
if (isMountRoot1)
|
if (isMountRoot1)
|
||||||
m9 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_ROOT1, &g_settings.flashupdate_createimage_add_root1,
|
m9 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_ROOT1, &g_settings.flashupdate_createimage_add_root1,
|
||||||
MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true);
|
MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true);
|
||||||
@@ -1343,19 +1413,21 @@ int CFlashExpertSetup::showMenu()
|
|||||||
#endif
|
#endif
|
||||||
rootfsSetup->addItem(m6); // include kernel
|
rootfsSetup->addItem(m6); // include kernel
|
||||||
|
|
||||||
if (cs_get_revision() != 12) { // not kronos
|
if (cs_get_revision() != 12) // not kronos
|
||||||
|
{
|
||||||
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
|
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
|
||||||
const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank";
|
const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank";
|
||||||
char mText[512] = {0};
|
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);
|
CMenuOptionChooser *m7 = new CMenuOptionChooser(mText, &(cfe->createimage_other), MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true);
|
||||||
|
|
||||||
rootfsSetup->addItem(GenericMenuSeparatorLine);
|
rootfsSetup->addItem(GenericMenuSeparatorLine);
|
||||||
rootfsSetup->addItem(m7); // create image for other STB
|
rootfsSetup->addItem(m7); // create image for other STB
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
cfe->createimage_other = 0;
|
cfe->createimage_other = 0;
|
||||||
|
|
||||||
int res = rootfsSetup->exec (NULL, "");
|
int res = rootfsSetup->exec(NULL, "");
|
||||||
delete rootfsSetup;
|
delete rootfsSetup;
|
||||||
|
|
||||||
cfe->createimage_other = 0;
|
cfe->createimage_other = 0;
|
||||||
|
@@ -30,7 +30,6 @@
|
|||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __update__
|
#ifndef __update__
|
||||||
#define __update__
|
#define __update__
|
||||||
|
|
||||||
@@ -60,17 +59,16 @@ class CFlashUpdate : public CProgressWindow
|
|||||||
int menu_ret;
|
int menu_ret;
|
||||||
int softupdate_mode;
|
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 selectHttpImage(void);
|
||||||
bool getUpdateImage(const std::string & version);
|
bool getUpdateImage(const std::string &version);
|
||||||
bool checkVersion4Update();
|
bool checkVersion4Update();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CFlashUpdate();
|
CFlashUpdate();
|
||||||
int exec( CMenuTarget* parent, const std::string & actionKey );
|
int exec(CMenuTarget *parent, const std::string &actionKey);
|
||||||
bool checkOnlineVersion();
|
bool checkOnlineVersion();
|
||||||
void enableNotify(bool enable) { notify = enable; }
|
void enableNotify(bool enable) { notify = enable; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CFlashExpert : public CProgressWindow
|
class CFlashExpert : public CProgressWindow
|
||||||
@@ -79,13 +77,13 @@ class CFlashExpert : public CProgressWindow
|
|||||||
int selectedMTD;
|
int selectedMTD;
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
int showMTDSelector(const std::string & actionkey);
|
int showMTDSelector(const std::string &actionkey);
|
||||||
int showFileSelector(const std::string & actionkey);
|
int showFileSelector(const std::string &actionkey);
|
||||||
|
|
||||||
bool checkSize(int mtd, std::string &backupFile);
|
bool checkSize(int mtd, std::string &backupFile);
|
||||||
#ifdef BOXMODEL_CST_HD2
|
#ifdef BOXMODEL_CST_HD2
|
||||||
bool readDevtableFile(std::string &devtableFile, CMkfsJFFS2::v_devtable_t &v_devtable);
|
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
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -95,11 +93,10 @@ class CFlashExpert : public CProgressWindow
|
|||||||
int createimage_other;
|
int createimage_other;
|
||||||
#endif
|
#endif
|
||||||
CFlashExpert();
|
CFlashExpert();
|
||||||
static CFlashExpert* getInstance();
|
static CFlashExpert *getInstance();
|
||||||
int exec(CMenuTarget* parent, const std::string & actionKey);
|
int exec(CMenuTarget *parent, const std::string &actionKey);
|
||||||
void writemtd(const std::string & filename, int mtdNumber);
|
void writemtd(const std::string &filename, int mtdNumber);
|
||||||
void readmtd(int readmtd);
|
void readmtd(int readmtd);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef BOXMODEL_CST_HD2
|
#ifdef BOXMODEL_CST_HD2
|
||||||
@@ -113,9 +110,9 @@ class CFlashExpertSetup : public CMenuTarget
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CFlashExpertSetup();
|
CFlashExpertSetup();
|
||||||
// ~CFlashExpertSetup();
|
//~CFlashExpertSetup();
|
||||||
|
|
||||||
int exec(CMenuTarget* parent, const std::string &actionKey);
|
int exec(CMenuTarget *parent, const std::string &actionKey);
|
||||||
};
|
};
|
||||||
#endif // BOXMODEL_CST_HD2
|
#endif // BOXMODEL_CST_HD2
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user