mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 17:31:20 +02:00
- update-settings: formatting code using astyle; some manual code nicenings
Conflicts: src/gui/update_settings.cpp Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -69,49 +69,51 @@ CUpdateSettings::~CUpdateSettings()
|
|||||||
#define SOFTUPDATE_NAME_MODE1_OPTION_COUNT 3
|
#define SOFTUPDATE_NAME_MODE1_OPTION_COUNT 3
|
||||||
const CMenuOptionChooser::keyval SOFTUPDATE_NAME_MODE1_OPTIONS[SOFTUPDATE_NAME_MODE1_OPTION_COUNT] =
|
const CMenuOptionChooser::keyval SOFTUPDATE_NAME_MODE1_OPTIONS[SOFTUPDATE_NAME_MODE1_OPTION_COUNT] =
|
||||||
{
|
{
|
||||||
{ CExtUpdate::SOFTUPDATE_NAME_DEFAULT, LOCALE_FLASHUPDATE_NAMEMODE1_DEFAULT },
|
{ CExtUpdate::SOFTUPDATE_NAME_DEFAULT, LOCALE_FLASHUPDATE_NAMEMODE1_DEFAULT },
|
||||||
{ CExtUpdate::SOFTUPDATE_NAME_HOSTNAME_TIME, LOCALE_FLASHUPDATE_NAMEMODE1_HOSTNAME_TIME },
|
{ CExtUpdate::SOFTUPDATE_NAME_HOSTNAME_TIME, LOCALE_FLASHUPDATE_NAMEMODE1_HOSTNAME_TIME },
|
||||||
{ CExtUpdate::SOFTUPDATE_NAME_ORGNAME_TIME, LOCALE_FLASHUPDATE_NAMEMODE1_ORGNAME_TIME }
|
{ CExtUpdate::SOFTUPDATE_NAME_ORGNAME_TIME, LOCALE_FLASHUPDATE_NAMEMODE1_ORGNAME_TIME }
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SOFTUPDATE_NAME_MODE2_OPTION_COUNT 2
|
#define SOFTUPDATE_NAME_MODE2_OPTION_COUNT 2
|
||||||
const CMenuOptionChooser::keyval SOFTUPDATE_NAME_MODE2_OPTIONS[SOFTUPDATE_NAME_MODE2_OPTION_COUNT] =
|
const CMenuOptionChooser::keyval SOFTUPDATE_NAME_MODE2_OPTIONS[SOFTUPDATE_NAME_MODE2_OPTION_COUNT] =
|
||||||
{
|
{
|
||||||
{ CExtUpdate::SOFTUPDATE_NAME_DEFAULT, LOCALE_FLASHUPDATE_NAMEMODE2_DEFAULT },
|
{ CExtUpdate::SOFTUPDATE_NAME_DEFAULT, LOCALE_FLASHUPDATE_NAMEMODE2_DEFAULT },
|
||||||
{ CExtUpdate::SOFTUPDATE_NAME_HOSTNAME_TIME, LOCALE_FLASHUPDATE_NAMEMODE2_HOSTNAME_TIME }
|
{ CExtUpdate::SOFTUPDATE_NAME_HOSTNAME_TIME, LOCALE_FLASHUPDATE_NAMEMODE2_HOSTNAME_TIME }
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const CMenuOptionChooser::keyval AUTOUPDATE_CHECK_OPTIONS[] =
|
const CMenuOptionChooser::keyval AUTOUPDATE_CHECK_OPTIONS[] =
|
||||||
{
|
{
|
||||||
{ -1, LOCALE_AUTO_UPDATE_CHECK_ON_START_ONLY },
|
{ -1, LOCALE_AUTO_UPDATE_CHECK_ON_START_ONLY },
|
||||||
{ 0, LOCALE_AUTO_UPDATE_CHECK_OFF },
|
{ 0, LOCALE_AUTO_UPDATE_CHECK_OFF },
|
||||||
{ 6, LOCALE_AUTO_UPDATE_CHECK_6_HOURS },
|
{ 6, LOCALE_AUTO_UPDATE_CHECK_6_HOURS },
|
||||||
{ 24, LOCALE_AUTO_UPDATE_CHECK_DAILY },
|
{ 24, LOCALE_AUTO_UPDATE_CHECK_DAILY },
|
||||||
{ 168, LOCALE_AUTO_UPDATE_CHECK_WEEKLY },
|
{ 168, LOCALE_AUTO_UPDATE_CHECK_WEEKLY },
|
||||||
{ 672, LOCALE_AUTO_UPDATE_CHECK_MONTHLY }
|
{ 672, LOCALE_AUTO_UPDATE_CHECK_MONTHLY }
|
||||||
};
|
};
|
||||||
size_t auto_update_options_count = sizeof(AUTOUPDATE_CHECK_OPTIONS)/sizeof(AUTOUPDATE_CHECK_OPTIONS[0]);
|
size_t auto_update_options_count = sizeof(AUTOUPDATE_CHECK_OPTIONS) / sizeof(AUTOUPDATE_CHECK_OPTIONS[0]);
|
||||||
|
|
||||||
int CUpdateSettings::exec(CMenuTarget* parent, const std::string &actionKey)
|
int CUpdateSettings::exec(CMenuTarget *parent, const std::string &actionKey)
|
||||||
{
|
{
|
||||||
dprintf(DEBUG_DEBUG, "init software-update settings\n");
|
dprintf(DEBUG_DEBUG, "init software-update settings\n");
|
||||||
int res = menu_return::RETURN_REPAINT;
|
int res = menu_return::RETURN_REPAINT;
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
parent->hide();
|
parent->hide();
|
||||||
|
|
||||||
if(actionKey == "update_dir") {
|
if (actionKey == "update_dir")
|
||||||
|
{
|
||||||
const char *action_str = "update";
|
const char *action_str = "update";
|
||||||
if(chooserDir(g_settings.update_dir, true, action_str, true))
|
if (chooserDir(g_settings.update_dir, true, action_str, true))
|
||||||
printf("[neutrino] new %s dir %s\n", action_str, g_settings.update_dir.c_str());
|
printf("[neutrino] new %s dir %s\n", action_str, g_settings.update_dir.c_str());
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#ifndef USE_SMS_INPUT
|
#ifndef USE_SMS_INPUT
|
||||||
else if(actionKey == "select_url_config_file"){
|
else if (actionKey == "select_url_config_file")
|
||||||
CFileBrowser fileBrowser;
|
{
|
||||||
CFileFilter fileFilter;
|
CFileBrowser fileBrowser;
|
||||||
|
CFileFilter fileFilter;
|
||||||
|
|
||||||
fileFilter.addFilter("conf");
|
fileFilter.addFilter("conf");
|
||||||
fileFilter.addFilter("urls");
|
fileFilter.addFilter("urls");
|
||||||
@@ -127,38 +129,35 @@ int CUpdateSettings::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init options for software update */
|
// init options for software update
|
||||||
int CUpdateSettings::initMenu()
|
int CUpdateSettings::initMenu()
|
||||||
{
|
{
|
||||||
COnOffNotifier* OnOffNotifier = new COnOffNotifier(0);
|
COnOffNotifier *OnOffNotifier = new COnOffNotifier(0);
|
||||||
|
|
||||||
CMenuWidget w_upsettings(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE, width, MN_WIDGET_ID_SOFTWAREUPDATE_SETTINGS);
|
CMenuWidget w_upsettings(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE, width, MN_WIDGET_ID_SOFTWAREUPDATE_SETTINGS);
|
||||||
w_upsettings.addIntroItems(LOCALE_FLASHUPDATE_SETTINGS);
|
w_upsettings.addIntroItems(LOCALE_FLASHUPDATE_SETTINGS);
|
||||||
|
|
||||||
CMenuForwarder * fw_url = NULL;
|
CMenuForwarder *fw_url = new CMenuForwarder(LOCALE_FLASHUPDATE_URL_FILE, true, g_settings.softupdate_url_file, this, "select_url_config_file", CRCInput::RC_green);
|
||||||
if (file_exists(g_settings.softupdate_url_file.c_str()))
|
//fw_url->setHint("", LOCALE_MENU_HINT_XXX);
|
||||||
fw_url = new CMenuForwarder(LOCALE_FLASHUPDATE_URL_FILE, true, g_settings.softupdate_url_file, this, "select_url_config_file", CRCInput::RC_green);
|
CMenuForwarder *fw_update_dir = new CMenuForwarder(LOCALE_EXTRA_UPDATE_DIR, true, g_settings.update_dir, this, "update_dir", CRCInput::RC_red);
|
||||||
|
//fw_update_dir->setHint("", LOCALE_MENU_HINT_XXX);
|
||||||
// fw_url->setHint("", LOCALE_MENU_HINT_XXX);
|
|
||||||
CMenuForwarder * fw_update_dir = new CMenuForwarder(LOCALE_EXTRA_UPDATE_DIR, true, g_settings.update_dir , this, "update_dir", CRCInput::RC_red);
|
|
||||||
// fw_update_dir->setHint("", LOCALE_MENU_HINT_XXX);
|
|
||||||
#if ENABLE_EXTUPDATE
|
#if ENABLE_EXTUPDATE
|
||||||
CMenuOptionChooser *name_backup = new CMenuOptionChooser(LOCALE_FLASHUPDATE_NAMEMODE2, &g_settings.softupdate_name_mode_backup, SOFTUPDATE_NAME_MODE2_OPTIONS, SOFTUPDATE_NAME_MODE2_OPTION_COUNT, true);
|
CMenuOptionChooser *name_backup = new CMenuOptionChooser(LOCALE_FLASHUPDATE_NAMEMODE2, &g_settings.softupdate_name_mode_backup, SOFTUPDATE_NAME_MODE2_OPTIONS, SOFTUPDATE_NAME_MODE2_OPTION_COUNT, true);
|
||||||
// name_backup->setHint("", LOCALE_MENU_HINT_XXX);
|
//name_backup->setHint("", LOCALE_MENU_HINT_XXX);
|
||||||
|
|
||||||
#ifndef BOXMODEL_CST_HD2
|
#ifndef BOXMODEL_CST_HD2
|
||||||
CMenuOptionChooser *apply_settings = new CMenuOptionChooser(LOCALE_FLASHUPDATE_MENU_APPLY_SETTINGS, &g_settings.apply_settings, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, OnOffNotifier);
|
CMenuOptionChooser *apply_settings = new CMenuOptionChooser(LOCALE_FLASHUPDATE_MENU_APPLY_SETTINGS, &g_settings.apply_settings, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, OnOffNotifier);
|
||||||
// apply_settings->setHint("", LOCALE_MENU_HINT_XXX);
|
//apply_settings->setHint("", LOCALE_MENU_HINT_XXX);
|
||||||
|
|
||||||
CMenuOptionChooser *name_apply = new CMenuOptionChooser(LOCALE_FLASHUPDATE_NAMEMODE1, &g_settings.softupdate_name_mode_apply, SOFTUPDATE_NAME_MODE1_OPTIONS, SOFTUPDATE_NAME_MODE1_OPTION_COUNT, g_settings.apply_settings);
|
CMenuOptionChooser *name_apply = new CMenuOptionChooser(LOCALE_FLASHUPDATE_NAMEMODE1, &g_settings.softupdate_name_mode_apply, SOFTUPDATE_NAME_MODE1_OPTIONS, SOFTUPDATE_NAME_MODE1_OPTION_COUNT, g_settings.apply_settings);
|
||||||
// name_apply->setHint("", LOCALE_MENU_HINT_XXX);
|
//name_apply->setHint("", LOCALE_MENU_HINT_XXX);
|
||||||
OnOffNotifier->addItem(name_apply);
|
OnOffNotifier->addItem(name_apply);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
CMenuOptionChooser *apply_kernel = new CMenuOptionChooser(LOCALE_FLASHUPDATE_MENU_APPLY_KERNEL, &g_settings.apply_kernel, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, g_settings.apply_settings);
|
CMenuOptionChooser *apply_kernel = new CMenuOptionChooser(LOCALE_FLASHUPDATE_MENU_APPLY_KERNEL, &g_settings.apply_kernel, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, g_settings.apply_settings);
|
||||||
// apply_kernel->setHint("", LOCALE_MENU_HINT_XXX);
|
//apply_kernel->setHint("", LOCALE_MENU_HINT_XXX);
|
||||||
OnOffNotifier->addItem(apply_kernel);
|
OnOffNotifier->addItem(apply_kernel);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -168,7 +167,8 @@ int CUpdateSettings::initMenu()
|
|||||||
|
|
||||||
#if ENABLE_PKG_MANAGEMENT
|
#if ENABLE_PKG_MANAGEMENT
|
||||||
CMenuOptionChooser *package_autocheck = NULL;
|
CMenuOptionChooser *package_autocheck = NULL;
|
||||||
if (COPKGManager::hasOpkgSupport()){
|
if (COPKGManager::hasOpkgSupport())
|
||||||
|
{
|
||||||
package_autocheck = new CMenuOptionChooser(LOCALE_FLASHUPDATE_AUTOCHECK_PACKAGES, &g_settings.softupdate_autocheck_packages, AUTOUPDATE_CHECK_OPTIONS, auto_update_options_count, true, this);
|
package_autocheck = new CMenuOptionChooser(LOCALE_FLASHUPDATE_AUTOCHECK_PACKAGES, &g_settings.softupdate_autocheck_packages, AUTOUPDATE_CHECK_OPTIONS, auto_update_options_count, true, this);
|
||||||
package_autocheck->setHint("", LOCALE_MENU_HINT_AUTO_UPDATE_CHECK);
|
package_autocheck->setHint("", LOCALE_MENU_HINT_AUTO_UPDATE_CHECK);
|
||||||
}
|
}
|
||||||
@@ -194,13 +194,13 @@ int CUpdateSettings::initMenu()
|
|||||||
w_upsettings.addItem(apply_kernel);
|
w_upsettings.addItem(apply_kernel);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int res = w_upsettings.exec (NULL, "");
|
int res = w_upsettings.exec(NULL, "");
|
||||||
delete OnOffNotifier;
|
delete OnOffNotifier;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUpdateSettings::changeNotify(const neutrino_locale_t OptionName, void * /* data */)
|
bool CUpdateSettings::changeNotify(const neutrino_locale_t OptionName, void * /*data*/)
|
||||||
{
|
{
|
||||||
if (ARE_LOCALES_EQUAL(OptionName, LOCALE_FLASHUPDATE_AUTOCHECK))
|
if (ARE_LOCALES_EQUAL(OptionName, LOCALE_FLASHUPDATE_AUTOCHECK))
|
||||||
{
|
{
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
|
||||||
// #define USE_SMS_INPUT
|
//#define USE_SMS_INPUT
|
||||||
|
|
||||||
#ifdef USE_SMS_INPUT
|
#ifdef USE_SMS_INPUT
|
||||||
#include "gui/widget/stringinput.h"
|
#include "gui/widget/stringinput.h"
|
||||||
@@ -44,14 +44,14 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
//helper class to enable/disable update config url item
|
// helper class to enable/disable update config url item
|
||||||
class CUrlConfigSetupNotifier : public CChangeObserver
|
class CUrlConfigSetupNotifier : public CChangeObserver
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
CMenuItem* toDisable[2];
|
CMenuItem *toDisable[2];
|
||||||
CMenuForwarder * updateItem;
|
CMenuForwarder *updateItem;
|
||||||
public:
|
public:
|
||||||
CUrlConfigSetupNotifier( CMenuItem*, CMenuItem*, CMenuForwarder *);
|
CUrlConfigSetupNotifier(CMenuItem *, CMenuItem *, CMenuForwarder *);
|
||||||
bool changeNotify(const neutrino_locale_t = NONEXISTANT_LOCALE, void *data = NULL);
|
bool changeNotify(const neutrino_locale_t = NONEXISTANT_LOCALE, void *data = NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,10 +65,10 @@ class CUpdateSettings : public CMenuTarget, CChangeObserver
|
|||||||
CStringInputSMS *input_url_file;
|
CStringInputSMS *input_url_file;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CUpdateSettings();
|
CUpdateSettings();
|
||||||
~CUpdateSettings();
|
~CUpdateSettings();
|
||||||
int exec(CMenuTarget* parent, const std::string & actionKey);
|
int exec(CMenuTarget *parent, const std::string &actionKey);
|
||||||
bool changeNotify(const neutrino_locale_t = NONEXISTANT_LOCALE, void *data = NULL);
|
bool changeNotify(const neutrino_locale_t = NONEXISTANT_LOCALE, void *data = NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user