diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 6e4d34163..651df3d38 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -2266,6 +2266,7 @@ servicemenu.restart_refused_recording Aufnahme läuft. Neustart nicht möglich. servicemenu.scants Kanalsuche servicemenu.update Software-Aktualisierung settings.backup System-Einstellungen sichern +settings.backup_dir Nach %s sichern?\n"Nein" wählt ein anderes Verzeichnis settings.backup_failed Sicherung fehlgeschlagen! settings.help Hilfe settings.menu_hints Hinweise anzeigen diff --git a/data/locale/english.locale b/data/locale/english.locale index 5e3b5c825..7106641bc 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -2266,6 +2266,7 @@ servicemenu.restart_refused_recording Cant restart, recording in progress servicemenu.scants Servicescan servicemenu.update Software Update settings.backup Save system settings +settings.backup_dir Save to %s?\n"No" chooses another directory. settings.backup_failed Backup failed! settings.help Help settings.menu_hints Show menu hints diff --git a/src/gui/settings_manager.cpp b/src/gui/settings_manager.cpp index f2f8ef170..526c4b269 100644 --- a/src/gui/settings_manager.cpp +++ b/src/gui/settings_manager.cpp @@ -75,8 +75,9 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey) { fileFilter.addFilter("conf"); fileBrowser.Filter = &fileFilter; - if (fileBrowser.exec(CONFIGDIR) == true) + if (fileBrowser.exec(g_settings.backup_dir.c_str()) == true) { + g_settings.backup_dir = fileBrowser.getCurrentDir(); CNeutrinoApp::getInstance()->loadSetup(fileBrowser.getSelectedFile()->Name.c_str()); CColorSetupNotifier *colorSetupNotifier = new CColorSetupNotifier; colorSetupNotifier->changeNotify(NONEXISTANT_LOCALE, NULL); @@ -89,48 +90,71 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey) } else if(actionKey == "saveconfig") { - fileBrowser.Dir_Mode = true; - if (fileBrowser.exec("/media") == true) - { - std::string fname = "neutrino.conf"; - CKeyboardInput * sms = new CKeyboardInput(LOCALE_EXTRA_SAVECONFIG, &fname); - sms->exec(NULL, ""); + char msgtxt[1024]; + snprintf(msgtxt, sizeof(msgtxt), g_Locale->getText(LOCALE_SETTINGS_BACKUP_DIR), g_settings.backup_dir.c_str()); - std::string sname = fileBrowser.getSelectedFile()->Name + "/" + fname; - printf("[neutrino] save settings: %s\n", sname.c_str()); - CNeutrinoApp::getInstance()->saveSetup(sname.c_str()); - delete sms; + int result = ShowMsg(LOCALE_EXTRA_SAVECONFIG, msgtxt, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo); + if (result == CMsgBox::mbrNo) + { + fileBrowser.Dir_Mode = true; + if (fileBrowser.exec(g_settings.backup_dir.c_str()) == true) + g_settings.backup_dir = fileBrowser.getSelectedFile()->Name; + else + return res; } + + std::string fname = "neutrino.conf"; + CKeyboardInput * sms = new CKeyboardInput(LOCALE_EXTRA_SAVECONFIG, &fname); + sms->exec(NULL, ""); + delete sms; + + std::string sname = g_settings.backup_dir + "/" + fname; + printf("[neutrino] save settings: %s\n", sname.c_str()); + CNeutrinoApp::getInstance()->saveSetup(sname.c_str()); + return res; } else if(actionKey == "backup") { - fileBrowser.Dir_Mode = true; - if (fileBrowser.exec("/media") == true) + char msgtxt[1024]; + snprintf(msgtxt, sizeof(msgtxt), g_Locale->getText(LOCALE_SETTINGS_BACKUP_DIR), g_settings.backup_dir.c_str()); + + int result = ShowMsg(LOCALE_SETTINGS_BACKUP, msgtxt, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo); + if (result == CMsgBox::mbrNo) { - struct statfs s; - int ret = ::statfs(fileBrowser.getSelectedFile()->Name.c_str(), &s); - if(ret == 0 && s.f_type != 0x72b6L) /*jffs2*/ - { - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SETTINGS_BACKUP)); - hintBox->paint(); - const char backup_sh[] = TARGET_PREFIX "/bin/backup.sh"; - printf("backup: executing [%s %s]\n", backup_sh, fileBrowser.getSelectedFile()->Name.c_str()); - my_system(2, backup_sh, fileBrowser.getSelectedFile()->Name.c_str()); - hintBox->hide(); - delete hintBox; - } + fileBrowser.Dir_Mode = true; + if (fileBrowser.exec(g_settings.backup_dir.c_str()) == true) + g_settings.backup_dir = fileBrowser.getSelectedFile()->Name; else - ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_ERROR); + return res; } + + struct statfs s; + int ret = ::statfs(g_settings.backup_dir.c_str(), &s); + if (ret == 0 && s.f_type != 0x72b6L) /*jffs2*/ + { + CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SETTINGS_BACKUP)); + hintBox->paint(); + + const char backup_sh[] = TARGET_PREFIX "/bin/backup.sh"; + printf("backup: executing [%s %s]\n", backup_sh, g_settings.backup_dir.c_str()); + my_system(2, backup_sh, g_settings.backup_dir.c_str()); + + hintBox->hide(); + delete hintBox; + } + else + ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_ERROR); + return res; } else if(actionKey == "restore") { fileFilter.addFilter("tar"); fileBrowser.Filter = &fileFilter; - if (fileBrowser.exec("/media") == true) + if (fileBrowser.exec(g_settings.backup_dir.c_str()) == true) { + g_settings.backup_dir = fileBrowser.getCurrentDir(); int result = ShowMsg(LOCALE_SETTINGS_RESTORE, g_Locale->getText(LOCALE_SETTINGS_RESTORE_WARN), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo); if(result == CMsgBox::mbrYes) { diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 522a885f1..39d26c862 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -827,6 +827,8 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.font_scaling_x = configfile.getInt32("font_scaling_x", 100); g_settings.font_scaling_y = configfile.getInt32("font_scaling_y", 100); + g_settings.backup_dir = configfile.getString("backup_dir", "/media"); + g_settings.update_dir = configfile.getString("update_dir", "/tmp"); g_settings.update_dir_opkg = configfile.getString("update_dir_opkg", g_settings.update_dir); @@ -1446,6 +1448,8 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setString("softupdate_proxyusername" , g_settings.softupdate_proxyusername ); configfile.setString("softupdate_proxypassword" , g_settings.softupdate_proxypassword ); + configfile.setString("backup_dir", g_settings.backup_dir); + configfile.setString("update_dir", g_settings.update_dir); configfile.setString("update_dir_opkg", g_settings.update_dir_opkg); diff --git a/src/system/locals.h b/src/system/locals.h index d1260c9ef..339ad53f9 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -2293,6 +2293,7 @@ typedef enum LOCALE_SERVICEMENU_SCANTS, LOCALE_SERVICEMENU_UPDATE, LOCALE_SETTINGS_BACKUP, + LOCALE_SETTINGS_BACKUP_DIR, LOCALE_SETTINGS_BACKUP_FAILED, LOCALE_SETTINGS_HELP, LOCALE_SETTINGS_MENU_HINTS, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 61003a67d..013449970 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -2293,6 +2293,7 @@ const char * locale_real_names[] = "servicemenu.scants", "servicemenu.update", "settings.backup", + "settings.backup_dir", "settings.backup_failed", "settings.help", "settings.menu_hints", diff --git a/src/system/settings.h b/src/system/settings.h index 7242b221a..e813dd0f0 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -668,6 +668,8 @@ struct SNeutrinoSettings int flashupdate_createimage_add_spare; int flashupdate_createimage_add_kernel; + std::string backup_dir; + std::string update_dir; std::string update_dir_opkg;