mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 09:21:09 +02:00
convert most char[...] configuration values to std::string
Signed-off-by: Jacek Jendrzej <crashdvb@googlemail.com>
Origin commit data
------------------
Commit: cbc9299df8
Author: martii <m4rtii@gmx.de>
Date: 2013-06-11 (Tue, 11 Jun 2013)
This commit is contained in:
@@ -1505,6 +1505,23 @@ CMenuOptionStringChooser::CMenuOptionStringChooser(const char* OptionName, char*
|
||||
active = Active;
|
||||
optionValue = OptionValue;
|
||||
observ = Observ;
|
||||
optionValueString = NULL;
|
||||
|
||||
directKey = DirectKey;
|
||||
iconName = IconName;
|
||||
pulldown = Pulldown;
|
||||
}
|
||||
|
||||
CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown)
|
||||
{
|
||||
height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
optionNameString = g_Locale->getText(OptionName);
|
||||
optionName = OptionName;
|
||||
active = Active;
|
||||
optionValue = (char *) OptionValue->c_str();
|
||||
optionValueString = OptionValue;
|
||||
observ = Observ;
|
||||
optionValueString = NULL;
|
||||
|
||||
directKey = DirectKey;
|
||||
iconName = IconName;
|
||||
@@ -1555,8 +1572,13 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent)
|
||||
}
|
||||
menu->exec(NULL, "");
|
||||
ret = menu_return::RETURN_REPAINT;
|
||||
if(select >= 0)
|
||||
strcpy(optionValue, options[select].c_str());
|
||||
if(select >= 0) {
|
||||
if (optionValueString) {
|
||||
*optionValueString = options[select];
|
||||
optionValue = (char *)optionValueString->c_str();
|
||||
} else
|
||||
strcpy(optionValue, options[select].c_str());
|
||||
}
|
||||
delete menu;
|
||||
delete selector;
|
||||
} else {
|
||||
@@ -1564,12 +1586,26 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent)
|
||||
for(unsigned int count = 0; count < options.size(); count++) {
|
||||
if (strcmp(options[count].c_str(), optionValue) == 0) {
|
||||
if(msg == CRCInput::RC_left) {
|
||||
if(count > 0)
|
||||
strcpy(optionValue, options[(count - 1) % options.size()].c_str());
|
||||
else
|
||||
strcpy(optionValue, options[options.size() - 1].c_str());
|
||||
} else
|
||||
strcpy(optionValue, options[(count + 1) % options.size()].c_str());
|
||||
if(count > 0) {
|
||||
if (optionValueString) {
|
||||
*optionValueString = options[(count - 1) % options.size()];
|
||||
optionValue = (char *)optionValueString->c_str();
|
||||
} else
|
||||
strcpy(optionValue, options[(count - 1) % options.size()].c_str());
|
||||
} else {
|
||||
if (optionValueString) {
|
||||
*optionValueString = options[options.size() - 1];
|
||||
optionValue = (char *)optionValueString->c_str();
|
||||
} else
|
||||
strcpy(optionValue, options[options.size() - 1].c_str());
|
||||
}
|
||||
} else {
|
||||
if (optionValueString) {
|
||||
*optionValueString = options[(count + 1) % options.size()];
|
||||
optionValue = (char *)optionValueString->c_str();
|
||||
} else
|
||||
strcpy(optionValue, options[(count + 1) % options.size()].c_str());
|
||||
}
|
||||
//wantsRepaint = true;
|
||||
break;
|
||||
}
|
||||
@@ -1621,7 +1657,7 @@ CMenuOptionLanguageChooser::~CMenuOptionLanguageChooser()
|
||||
|
||||
int CMenuOptionLanguageChooser::exec(CMenuTarget*)
|
||||
{
|
||||
strncpy(g_settings.language, optionValue.c_str(), sizeof(g_settings.language)-1);
|
||||
g_settings.language = optionValue;
|
||||
if(observ)
|
||||
observ->changeNotify(LOCALE_LANGUAGESETUP_SELECT, (void *) optionValue.c_str());
|
||||
return menu_return::RETURN_EXIT;
|
||||
|
@@ -371,12 +371,14 @@ class CMenuOptionStringChooser : public CMenuItem
|
||||
std::string optionNameString;
|
||||
int height;
|
||||
char * optionValue;
|
||||
std::string * optionValueString;
|
||||
std::vector<std::string> options;
|
||||
CChangeObserver * observ;
|
||||
bool pulldown;
|
||||
|
||||
public:
|
||||
CMenuOptionStringChooser(const neutrino_locale_t OptionName, char* OptionValue, bool Active = false, CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false);
|
||||
CMenuOptionStringChooser(const neutrino_locale_t OptionName, std::string* OptionValue, bool Active = false, CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false);
|
||||
CMenuOptionStringChooser(const char* OptionName, char* OptionValue, bool Active = false, CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false);
|
||||
|
||||
~CMenuOptionStringChooser();
|
||||
|
@@ -47,20 +47,14 @@ CMountChooser::CMountChooser(const neutrino_locale_t Name, const std::string & I
|
||||
char indexStr[2];
|
||||
for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++)
|
||||
{
|
||||
if (g_settings.network_nfs_local_dir[i] != NULL &&
|
||||
strcmp(g_settings.network_nfs_local_dir[i],"") != 0 &&
|
||||
(strstr(g_settings.network_nfs_mount_options1[i],"rw") != NULL ||
|
||||
strstr(g_settings.network_nfs_mount_options2[i],"rw") != NULL))
|
||||
if (!g_settings.network_nfs[i].local_dir.empty() &&
|
||||
(g_settings.network_nfs[i].mount_options1.find("rw") != string::npos ||
|
||||
g_settings.network_nfs[i].mount_options2.find("rw") != string::npos))
|
||||
{
|
||||
std::string s(g_settings.network_nfs_local_dir[i]);
|
||||
s += " (";
|
||||
s += g_settings.network_nfs_ip[i];
|
||||
s += ":";
|
||||
s += g_settings.network_nfs_dir[i];
|
||||
s +=")";
|
||||
snprintf(indexStr,2,"%d",i);
|
||||
std::string s = g_settings.network_nfs[i].local_dir + " (" + g_settings.network_nfs[i].ip + ":" + g_settings.network_nfs[i].dir + ")";
|
||||
snprintf(indexStr,sizeof(indexStr),"%d",i);
|
||||
addItem(new CMenuForwarderNonLocalized(s.c_str(),true,NULL,this,(std::string("MID:") + std::string(indexStr)).c_str()),
|
||||
(strcmp(selectedLocalDir,g_settings.network_nfs_local_dir[i]) == 0));
|
||||
selectedLocalDir == g_settings.network_nfs[i].local_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,8 +72,9 @@ int CMountChooser::exec(CMenuTarget* parent, const std::string & actionKey)
|
||||
{
|
||||
if (index)
|
||||
*index = mount_id;
|
||||
if (localDir)
|
||||
strcpy(localDir,g_settings.network_nfs_local_dir[mount_id]);
|
||||
|
||||
if (localDir.empty()) // ???
|
||||
localDir = g_settings.network_nfs[mount_id].local_dir;
|
||||
}
|
||||
hide();
|
||||
return menu_return::RETURN_EXIT;
|
||||
|
@@ -52,7 +52,7 @@ class CMountChooser : public CMenuWidget
|
||||
{
|
||||
private:
|
||||
int * index;
|
||||
char * localDir;
|
||||
std::string localDir;
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -566,9 +566,11 @@ void CDateInput::onAfterExec()
|
||||
}
|
||||
//-----------------------------#################################-------------------------------------------------------
|
||||
|
||||
CMACInput::CMACInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ)
|
||||
: CExtendedInput(Name, Value, Hint_1, Hint_2, Observ)
|
||||
CMACInput::CMACInput(const neutrino_locale_t Name, std::string &
|
||||
Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ)
|
||||
: CExtendedInput(Name, MAC, Hint_1, Hint_2, Observ)
|
||||
{
|
||||
mac = &Value;
|
||||
frameBuffer = CFrameBuffer::getInstance();
|
||||
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
|
||||
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
|
||||
@@ -600,7 +602,7 @@ void CMACInput::onBeforeExec()
|
||||
return;
|
||||
}
|
||||
int _mac[6];
|
||||
sscanf( value, "%x:%x:%x:%x:%x:%x", &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5] );
|
||||
sscanf( mac->c_str(), "%x:%x:%x:%x:%x:%x", &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5] );
|
||||
sprintf( value, "%02x:%02x:%02x:%02x:%02x:%02x", _mac[0], _mac[1], _mac[2], _mac[3], _mac[4], _mac[5]);
|
||||
}
|
||||
|
||||
@@ -610,7 +612,11 @@ void CMACInput::onAfterExec()
|
||||
sscanf( value, "%x:%x:%x:%x:%x:%x", &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5] );
|
||||
sprintf( value, "%02x:%02x:%02x:%02x:%02x:%02x", _mac[0], _mac[1], _mac[2], _mac[3], _mac[4], _mac[5]);
|
||||
if(strcmp(value,"00:00:00:00:00:00")==0)
|
||||
value[0] = 0; /* strcpy(value, ""); */
|
||||
{
|
||||
(*mac) = "";
|
||||
}
|
||||
else
|
||||
(*mac) = value;
|
||||
}
|
||||
|
||||
//-----------------------------#################################-------------------------------------------------------
|
||||
|
@@ -187,12 +187,15 @@ class CDateInput : public CExtendedInput
|
||||
|
||||
class CMACInput : public CExtendedInput
|
||||
{
|
||||
char MAC[32];
|
||||
std::string * mac;
|
||||
|
||||
protected:
|
||||
virtual void onBeforeExec();
|
||||
virtual void onAfterExec();
|
||||
|
||||
public:
|
||||
CMACInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL);
|
||||
CMACInput(const neutrino_locale_t Name, std::string & Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user