//open a message dialog with three buttons,
//yes:		applies networksettings and exit network setup
//no:		saves networksettings and exit network setup
//back: 	exit message dialog, goes back to network setup 
int CNetworkSetup::saveChangesDialog()
{
	if (!checkForIP())
		return 1;	

	// Save the settings after changes, if user wants to!
	int result = ShowLocalizedMessage(LOCALE_MAINSETTINGS_NETWORK,
					  LOCALE_NETWORKMENU_APPLY_SETTINGS_NOW,
					  CMessageBox::mbrYes,
					  CMessageBox::mbYes | CMessageBox::mbNo | CMessageBox::mbBack,
					  NEUTRINO_ICON_QUESTION,
					  width);
	
	switch(result)
	{
		case CMessageBox::mbrYes:
			applyNetworkSettings();
			return 0;
			break;
	
		case CMessageBox::mbrNo:
			saveNetworkSettings(true);
			return 0;
			break;
	
		default:
			restoreNetworkSettings(true);
			return 1;
			break;
	}
}
int CNetworkSetup::exec(CMenuTarget* parent, const std::string &actionKey)
{
	int   res = menu_return::RETURN_REPAINT;

	if (parent)
		parent->hide();

	if(actionKey=="networkapply")
	{
		applyNetworkSettings();
		readNetworkSettings();
		backupNetworkSettings();
		return res;
	}
	else if(actionKey=="networktest")
	{
		printf("[network setup] doing network test...\n");
#if 0
		testNetworkSettings(	networkConfig->address.c_str(),
					networkConfig->netmask.c_str(),
					networkConfig->broadcast.c_str(),
					networkConfig->gateway.c_str(),
					networkConfig->nameserver.c_str(),
					networkConfig->inet_static);
#endif
		testNetworkSettings();
		return res;
	}
	else if(actionKey=="networkshow")
	{
		dprintf(DEBUG_INFO, "show current network settings...\n");
		showCurrentNetworkSettings();
		return res;
	}
	else if(actionKey=="scanssid")
	{
		return showWlanList();
	}
	else if(actionKey=="restore")
	{
		int result =  	ShowMsg(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_RESET_SETTINGS_NOW), CMessageBox::mbrNo,
				CMessageBox::mbYes |
				CMessageBox::mbNo ,
				NEUTRINO_ICON_QUESTION,
				width);

		if (result ==  CMessageBox::mbrYes) {
			restoreNetworkSettings();
		}
		return res;
	}

	printf("[neutrino] init network setup...\n");
	res = showNetworkSetup();

	return res;
}
int CNetworkSetup::exec(CMenuTarget* parent, const std::string &actionKey)
{
	int   res = menu_return::RETURN_REPAINT;

	if (parent)
	{
		parent->hide();
	}
	
	if(actionKey=="networkapply")
	{
		applyNetworkSettings();
		return res;
	}
	else if(actionKey=="networktest")
	{
		printf("[network setup] doing network test...\n");
		testNetworkSettings();
		return res;
	}
	else if(actionKey=="networkshow")
	{
		dprintf(DEBUG_INFO, "show current network settings...\n");
		showCurrentNetworkSettings();
		return res;
	}
	else if(actionKey=="networksave")
	{
		saveNetworkSettings();
		return res;
	}

	printf("[neutrino] init network setup...\n");
	res = showNetworkSetup();
	
	return res;
}