* Software Update with apply the settings (Part9)

- Functions now available for internet & local update.
- Rename writemtdExt() to applySettings()
This commit is contained in:
micha-bbg
2012-11-05 08:13:50 +01:00
parent e145f9a5e8
commit 0c84840e10
7 changed files with 44 additions and 23 deletions

View File

@@ -436,6 +436,7 @@ filesystem.is.utf8 Dateisystem
filesystem.is.utf8.option.iso8859.1 ISO-8859-1
filesystem.is.utf8.option.utf8 UTF-8
flashupdate.actionreadflash lese Flash
flashupdate.apply_settings Sollen die aktuellen Einstellungen in das neue Image übernommen werden?
flashupdate.cantopenfile kann Datei nicht öffnen
flashupdate.cantopenmtd kann MTD nicht öffnen
flashupdate.checkupdate_internet Online nach Updates suchen

View File

@@ -436,6 +436,7 @@ filesystem.is.utf8 file system
filesystem.is.utf8.option.iso8859.1 ISO-8859-1
filesystem.is.utf8.option.utf8 UTF-8
flashupdate.actionreadflash reading
flashupdate.apply_settings Import current settings into new image?
flashupdate.cantopenfile can't open file
flashupdate.cantopenmtd can't open MTD
flashupdate.checkupdate_internet Check for online updates

View File

@@ -121,19 +121,25 @@ bool CExtUpdate::ErrorReset(bool modus, const std::string & msg1, const std::str
return false;
}
bool CExtUpdate::writemtdExt(const std::string & filename)
bool CExtUpdate::applySettings(const std::string & filename, int mode)
{
if(!FileHelpers)
FileHelpers = new CFileHelpers();
if (mode == MODE_EXPERT)
imgFilename = (std::string)g_settings.update_dir + "/" + FILESYSTEM_ENCODING_TO_UTF8_STRING(filename);
else
imgFilename = FILESYSTEM_ENCODING_TO_UTF8_STRING(filename);
DBG_TIMER_START()
bool ret = writemtdExt();
bool ret = applySettings();
DBG_TIMER_STOP("Image editing")
if (!ret) {
if (mtdRamError != "")
DisplayErrorMessage(mtdRamError.c_str());
}
else {
if (mode == MODE_EXPERT) {
if ((mtdNumber < 3) || (mtdNumber > 4)) {
const char *err = "invalid mtdNumber\n";
printf(err);
@@ -141,9 +147,11 @@ bool CExtUpdate::writemtdExt(const std::string & filename)
WRITE_UPDATE_LOG("ERROR: %s", err);
return false;
}
}
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SUCCESSFULLY), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO);
WRITE_UPDATE_LOG("\n");
WRITE_UPDATE_LOG("##### Settings taken. #####\n");
if (mode == MODE_EXPERT)
CFlashExpert::getInstance()->writemtd(filename, mtdNumber);
}
return ret;
@@ -166,7 +174,7 @@ bool CExtUpdate::isMtdramLoad()
return ret;
}
bool CExtUpdate::writemtdExt()
bool CExtUpdate::applySettings()
{
if(!hintBox)
hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_PROCESSED));

View File

@@ -55,7 +55,7 @@ class CExtUpdate
std::string mountPkt;
CFileHelpers* FileHelpers;
bool writemtdExt(void);
bool applySettings(void);
bool readBackupList(const std::string & dstPath);
bool copyFileList(const std::string & fileList, const std::string & dstPath);
bool readConfig(const std::string & Config);
@@ -69,11 +69,16 @@ class CExtUpdate
void updateLog(const char *buf);
public:
enum
{
MODE_EXPERT = 0,
MODE_SOFTUPDATE = 1
};
CExtUpdate();
~CExtUpdate();
static CExtUpdate* getInstance();
bool writemtdExt(const std::string & filename);
bool applySettings(const std::string & filename, int mode);
bool ErrorReset(bool modus, const std::string & msg1="", const std::string & msg2="");
};

View File

@@ -451,12 +451,16 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &)
CNeutrinoApp::getInstance()->exec(NULL, "savesettings");
sleep(2);
//flash it...
if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes)
if (!CExtUpdate::getInstance()->applySettings(filename, CExtUpdate::MODE_SOFTUPDATE))
return menu_return::RETURN_REPAINT;
#ifdef DEBUG1
if(1)
if(1) {
#else
if(!ft.program(filename, 80, 100))
if(!ft.program(filename, 80, 100)) {
#endif
{
hide();
ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, ft.getErrorMessage().c_str()); // UTF-8
return menu_return::RETURN_REPAINT;
@@ -690,7 +694,7 @@ int CFlashExpert::exec(CMenuTarget* parent, const std::string & actionKey)
showFileSelector("");
} else {
if(selectedMTD == 10) {
CExtUpdate::getInstance()->writemtdExt(actionKey);
CExtUpdate::getInstance()->applySettings(actionKey, CExtUpdate::MODE_EXPERT);
}
else if(selectedMTD==-1) {
writemtd(actionKey, MTD_OF_WHOLE_IMAGE);

View File

@@ -463,6 +463,7 @@ typedef enum
LOCALE_FILESYSTEM_IS_UTF8_OPTION_ISO8859_1,
LOCALE_FILESYSTEM_IS_UTF8_OPTION_UTF8,
LOCALE_FLASHUPDATE_ACTIONREADFLASH,
LOCALE_FLASHUPDATE_APPLY_SETTINGS,
LOCALE_FLASHUPDATE_CANTOPENFILE,
LOCALE_FLASHUPDATE_CANTOPENMTD,
LOCALE_FLASHUPDATE_CHECKUPDATE_INTERNET,

View File

@@ -463,6 +463,7 @@ const char * locale_real_names[] =
"filesystem.is.utf8.option.iso8859.1",
"filesystem.is.utf8.option.utf8",
"flashupdate.actionreadflash",
"flashupdate.apply_settings",
"flashupdate.cantopenfile",
"flashupdate.cantopenmtd",
"flashupdate.checkupdate_internet",