mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
convert most char[...] configuration values to std::string
Signed-off-by: Jacek Jendrzej <crashdvb@googlemail.com>
This commit is contained in:
@@ -202,14 +202,14 @@ int CNetworkSetup::showNetworkSetup()
|
||||
|
||||
int ifcount = scandir("/sys/class/net", &namelist, my_filter, alphasort);
|
||||
|
||||
CMenuOptionStringChooser * ifSelect = new CMenuOptionStringChooser(LOCALE_NETWORKMENU_SELECT_IF, g_settings.ifname, ifcount > 1, this, CRCInput::RC_nokey, "", true);
|
||||
CMenuOptionStringChooser * ifSelect = new CMenuOptionStringChooser(LOCALE_NETWORKMENU_SELECT_IF, &g_settings.ifname, ifcount > 1, this, CRCInput::RC_nokey, "", true);
|
||||
ifSelect->setHint("", LOCALE_MENU_HINT_NET_IF);
|
||||
|
||||
bool found = false;
|
||||
|
||||
for(int i = 0; i < ifcount; i++) {
|
||||
ifSelect->addOption(namelist[i]->d_name);
|
||||
if(strcmp(g_settings.ifname, namelist[i]->d_name) == 0)
|
||||
if(strcmp(g_settings.ifname.c_str(), namelist[i]->d_name) == 0)
|
||||
found = true;
|
||||
free(namelist[i]);
|
||||
}
|
||||
@@ -218,7 +218,7 @@ int CNetworkSetup::showNetworkSetup()
|
||||
free(namelist);
|
||||
|
||||
if(!found)
|
||||
strcpy(g_settings.ifname, "eth0");
|
||||
g_settings.ifname = "eth0";
|
||||
|
||||
networkConfig->readConfig(g_settings.ifname);
|
||||
readNetworkSettings();
|
||||
@@ -602,7 +602,7 @@ int CNetworkSetup::saveChangesDialog()
|
||||
//restores settings
|
||||
void CNetworkSetup::restoreNetworkSettings()
|
||||
{
|
||||
snprintf(g_settings.ifname, sizeof(g_settings.ifname), "%s", old_ifname.c_str());
|
||||
g_settings.ifname = old_ifname;
|
||||
networkConfig->readConfig(g_settings.ifname);//FIXME ?
|
||||
|
||||
mac_addr = networkConfig->mac_addr;
|
||||
@@ -649,7 +649,7 @@ bool CNetworkSetup::changeNotify(const neutrino_locale_t locale, void * Data)
|
||||
} else if(locale == LOCALE_NETWORKMENU_SELECT_IF) {
|
||||
networkConfig->readConfig(g_settings.ifname);
|
||||
readNetworkSettings();
|
||||
printf("CNetworkSetup::changeNotify: using %s, static %d\n", g_settings.ifname, CNetworkConfig::getInstance()->inet_static);
|
||||
printf("CNetworkSetup::changeNotify: using %s, static %d\n", g_settings.ifname.c_str(), CNetworkConfig::getInstance()->inet_static);
|
||||
|
||||
changeNotify(LOCALE_NETWORKMENU_DHCP, &CNetworkConfig::getInstance()->inet_static);
|
||||
|
||||
@@ -675,13 +675,7 @@ void CNetworkSetup::setWizardMode(bool mode)
|
||||
|
||||
void CNetworkSetup::showCurrentNetworkSettings()
|
||||
{
|
||||
char ip[16] = {0};
|
||||
char mask[16] = {0};
|
||||
char broadcast[16] = {0};
|
||||
char router[16] = {0};
|
||||
char nameserver[16] = {0};
|
||||
std::string text;
|
||||
|
||||
std::string ip, mask, broadcast, router, nameserver, text;
|
||||
netGetIP(g_settings.ifname, ip, mask, broadcast);
|
||||
if (ip[0] == 0) {
|
||||
text = g_Locale->getText(LOCALE_NETWORKMENU_INACTIVE_NETWORK);
|
||||
@@ -705,9 +699,9 @@ void CNetworkSetup::showCurrentNetworkSettings()
|
||||
ShowMsgUTF(LOCALE_NETWORKMENU_SHOW, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8
|
||||
}
|
||||
|
||||
const char * CNetworkSetup::mypinghost(const char * const host)
|
||||
const char * CNetworkSetup::mypinghost(std::string &host)
|
||||
{
|
||||
int retvalue = pinghost(host);
|
||||
int retvalue = pinghost(host.c_str());
|
||||
switch (retvalue)
|
||||
{
|
||||
case 1: return (g_Locale->getText(LOCALE_PING_OK));
|
||||
@@ -720,11 +714,7 @@ const char * CNetworkSetup::mypinghost(const char * const host)
|
||||
|
||||
void CNetworkSetup::testNetworkSettings()
|
||||
{
|
||||
char our_ip[16];
|
||||
char our_mask[16];
|
||||
char our_broadcast[16];
|
||||
char our_gateway[16];
|
||||
char our_nameserver[16];
|
||||
std::string our_ip, our_mask, our_broadcast, our_gateway, our_nameserver;
|
||||
|
||||
std::string text, testsite, offset = " ";
|
||||
|
||||
@@ -747,29 +737,29 @@ void CNetworkSetup::testNetworkSettings()
|
||||
|
||||
if (networkConfig->inet_static)
|
||||
{
|
||||
strcpy(our_ip, networkConfig->address.c_str());
|
||||
strcpy(our_mask, networkConfig->netmask.c_str());
|
||||
strcpy(our_broadcast, networkConfig->broadcast.c_str());
|
||||
strcpy(our_gateway, networkConfig->gateway.c_str());
|
||||
strcpy(our_nameserver, networkConfig->nameserver.c_str());
|
||||
our_ip = networkConfig->address;
|
||||
our_mask = networkConfig->netmask;
|
||||
our_broadcast = networkConfig->broadcast;
|
||||
our_gateway = networkConfig->gateway;
|
||||
our_nameserver = networkConfig->nameserver;
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME test with current, not changed ifname ?
|
||||
netGetIP((char *) old_ifname.c_str(), our_ip, our_mask, our_broadcast);
|
||||
netGetIP(old_ifname, our_ip, our_mask, our_broadcast);
|
||||
netGetDefaultRoute(our_gateway);
|
||||
netGetNameserver(our_nameserver);
|
||||
}
|
||||
|
||||
printf("testNw IP: %s\n", our_ip);
|
||||
printf("testNw IP: %s\n", our_ip.c_str());
|
||||
printf("testNw MAC-address: %s\n", old_mac_addr.c_str());
|
||||
printf("testNw Netmask: %s\n", our_mask);
|
||||
printf("testNw Broadcast: %s\n", our_broadcast);
|
||||
printf("testNw Gateway: %s\n", our_gateway);
|
||||
printf("testNw Nameserver: %s\n", our_nameserver);
|
||||
printf("testNw Netmask: %s\n", our_mask.c_str());
|
||||
printf("testNw Broadcast: %s\n", our_broadcast.c_str());
|
||||
printf("testNw Gateway: %s\n", our_gateway.c_str());
|
||||
printf("testNw Nameserver: %s\n", our_nameserver.c_str());
|
||||
printf("testNw Testsite: %s\n", testsite.c_str());
|
||||
|
||||
if (our_ip[0] == 0)
|
||||
if (our_ip.empty())
|
||||
{
|
||||
text = g_Locale->getText(LOCALE_NETWORKMENU_INACTIVE_NETWORK);
|
||||
}
|
||||
@@ -777,28 +767,28 @@ void CNetworkSetup::testNetworkSettings()
|
||||
{
|
||||
//Box
|
||||
text = "Box (" + old_mac_addr + "):\n";
|
||||
text += offset + (std::string)our_ip + " " + (std::string)mypinghost(our_ip) + "\n";
|
||||
text += offset + our_ip + " " + mypinghost(our_ip) + "\n";
|
||||
//Gateway
|
||||
text += (std::string)g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY) + " (Router):\n";
|
||||
text += offset + (std::string)our_gateway + " " + (std::string)mypinghost(our_gateway) + "\n";
|
||||
text += offset + our_gateway + " " + mypinghost(our_gateway) + "\n";
|
||||
//Nameserver
|
||||
text += (std::string)g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER) + ":\n";
|
||||
text += offset + (std::string)our_nameserver + " " + (std::string)mypinghost(our_nameserver) + "\n";
|
||||
text += offset + our_nameserver + " " + mypinghost(our_nameserver) + "\n";
|
||||
//NTPserver
|
||||
if ( (pinghost(our_nameserver) == 1) && g_settings.network_ntpenable && (g_settings.network_ntpserver != "") )
|
||||
if ( (pinghost(our_nameserver.c_str()) == 1) && g_settings.network_ntpenable && (g_settings.network_ntpserver != "") )
|
||||
{
|
||||
text += (std::string)g_Locale->getText(LOCALE_NETWORKMENU_NTPSERVER) + ":\n";
|
||||
text += offset + g_settings.network_ntpserver + " " + (std::string)mypinghost(g_settings.network_ntpserver.c_str()) + "\n";
|
||||
text += std::string(g_Locale->getText(LOCALE_NETWORKMENU_NTPSERVER)) + ":\n";
|
||||
text += offset + g_settings.network_ntpserver + " " + mypinghost(g_settings.network_ntpserver) + "\n";
|
||||
}
|
||||
//Wiki
|
||||
text += wiki_URL + ":\n";
|
||||
text += offset + "via IP (" + wiki_IP + "): " + (std::string)mypinghost(wiki_IP.c_str()) + "\n";
|
||||
if (pinghost(our_nameserver) == 1)
|
||||
text += offset + "via IP (" + wiki_IP + "): " + mypinghost(wiki_IP) + "\n";
|
||||
if (pinghost(our_nameserver.c_str()) == 1)
|
||||
{
|
||||
text += offset + "via DNS: " + (std::string)mypinghost(wiki_URL.c_str()) + "\n";
|
||||
text += offset + "via DNS: " + mypinghost(wiki_URL) + "\n";
|
||||
//testsite (or defaultsite)
|
||||
text += testsite + ":\n";
|
||||
text += offset + "via DNS: " + (std::string)mypinghost(testsite.c_str()) + "\n";
|
||||
text += offset + "via DNS: " + mypinghost(testsite) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user