//_include <mythcontext.h>
#include <unistd.h>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include "settings.h"

#include <string>
#include <fstream>
#include <sstream>
#include <stdexcept>
#include <vector>
#include <cassert>
#include <algorithm>
#include <tr1/unordered_map>


#include <sys/wait.h>   // For WIFEXITED on Mac OS X
#include <qapplication.h>
#include "mythcontext.h"
#include "libmyth/mythdialogs.h"
#include "mythdbcon.h"
#include "lcddevice.h"
#include "tv.h"
#include "programinfo.h"
#include "uitypes.h"
#include "remoteutil.h"
#include <qdir.h>
#include <qimage.h>
#include <stdlib.h>
#include <cstdlib>

#include "installsettings.h"
#include "installdialog.h"
#include "xorgsettings.h"
#include "password_manage.h"
#include "misc_settings.h"
#include "infrared.h"

#include <qsqldatabase.h>
#include <qsqlquery.h>
#include "mv_common.h"

int timezone_unknown = FALSE;
extern  HostParms hostparm;
extern DDCinfo ddcinfo;



bool displaymysqlonly = false ;
bool displayshownetwork =false ;
bool displayshowhostype = false ;
bool displayshowmisc =false ;
bool displayshowshutdown =false ;
bool displayshowadvanced = false;
bool displayshowsound = false ;
bool displayshowadvancedX = false;
bool displayaccesscontrol= false;
bool displayplugins = false;
bool displayuser = false;
bool displaywebuser = false;
bool displayddns = false;
bool displayinfrared = false;
bool displayscreensaver = false;
bool  install_hobbit = false;


static HostComboBox *ThemePainter()
{
    HostComboBox *gc = new HostComboBox("ThemePainter");
    gc->setLabel(QObject::tr("Paint Engine"));
    gc->addSelection(QObject::tr("Qt"), "qt");
    gc->addSelection(QObject::tr("OpenGL"), "opengl");
    gc->setHelpText(QObject::tr("This selects what Myth uses to draw.  If you have decent hardware, select OpenGL. Changing this requires a restart."));
    return gc;

}
static HostComboBox *HostMyhostname()
{
    HostComboBox *gc = new HostComboBox("HostMyhostname",true);
    gc->setLabel(QObject::tr("Hostname"));
    gc->addSelection("Envy");
    gc->addSelection("Greed");
    gc->addSelection("Lust");
    gc->addSelection("Sloth");
    gc->addSelection("Wrath");
    gc->addSelection("Gluttony");
    gc->addSelection("Pride");
    gc->addSelection("Humility");
    gc->addSelection("Generosity");
    gc->addSelection("Love");
    gc->addSelection("Kindness");
    gc->addSelection("SelfControl");
    gc->addSelection("Faith");
    gc->addSelection("Zeal");
    gc->addSelection("type_hostname_here");
    gc->setHelpText(QObject::tr("Hostname of this machine"));
    return gc;
};

static HostCheckBox *HostDHCPHostname()
{
    HostCheckBox *gc = new HostCheckBox("HostDHCPhostname");
    gc->setLabel(QObject::tr("Use Hostname provided by DHCP"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Checking this will use the hostname as provided by dhcp for the default interface.  If none is provided by DHCP it will use the hostname provided in the hostname box"));
    return gc;
};


static HostLineEdit *HostDDnslogin()
{
    HostLineEdit *gc = new HostLineEdit("HostDDnslogin");
        gc->setLabel(QObject::tr("Login"));
    gc->setValue("");
    gc->setHelpText(QObject::tr("Login for ddns account"));
    return gc;
};

static HostLineEdit *HostDDnspassword()
{
    HostLineEdit *gc = new HostLineEdit("HostDDnspassword");
    gc->setLabel(QObject::tr("Password"));
    gc->setValue("");
    gc->SetPasswordEcho(true);
    gc->setHelpText(QObject::tr("Password for ddns account."));
    return gc;
};

static HostLineEdit *HostDDnshostname()
{
    HostLineEdit *gc = new HostLineEdit("HostDDnshostname");
    gc->setLabel(QObject::tr("DDNS hostname"));
    gc->setValue("");
    gc->setHelpText(QObject::tr("Hostname used for DDNS."));
    return gc;
};

static HostCheckBox *HostDDnsEnable()
{
    HostCheckBox *gc = new HostCheckBox("HostDDnsEnable");
    gc->setLabel(QObject::tr("Enable DDNS support"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Update DDNS records at dyndns.com. Visit http://dyndns.com to setup your account."));
    return gc;
};

class DDnssettings: public TriggeredConfigurationGroup {
public:
    DDnssettings():
        TriggeredConfigurationGroup(false,false,false,false) {
         setLabel(QObject::tr("DDNS settings"));
        SetVertical(true);
        Setting* trigger = HostDDnsEnable() ;
        addChild(trigger);
        setTrigger(trigger);

        ConfigurationGroup* settings = new VerticalConfigurationGroup(false,false,false,false);
                settings->addChild(HostDDnshostname());
                settings->addChild(HostDDnslogin());
                settings->addChild(HostDDnspassword());

        addTarget("0", new VerticalConfigurationGroup(false, false));
        addTarget("1", settings);
    };
};




// static HostLineEdit *HostIP()
// {
//     HostLineEdit *gc = new HostLineEdit("HostIP");
//     gc->setLabel(QObject::tr("Ip address"));
//     gc->setValue("192.168.1.12");
//     gc->setHelpText(QObject::tr("IP address of the new installation"));
//     return gc;
// };
//
// static HostComboBox *HostNETMASK()
// {
//     HostComboBox *gc = new HostComboBox("HostNETMASK");
//         gc->setLabel(QObject::tr("Netmask"));
//         gc->addSelection("/0     0.0.0.0");
//         gc->addSelection("/1     128.0.0.0");
//         gc->addSelection("/2     192.0.0.0");
//         gc->addSelection("/3     224.0.0.0");
//         gc->addSelection("/4     240.0.0.0");
//         gc->addSelection("/5     248.0.0.0");
//         gc->addSelection("/6     252.0.0.0");
//         gc->addSelection("/7     254.0.0.0");
//         gc->addSelection("/8     255.0.0.0");
//         gc->addSelection("/9     255.128.0.0");
//         gc->addSelection("/10    255.192.0.0 ");
//         gc->addSelection("/11    255.224.0.0");
//         gc->addSelection("/12    255.240.0.0");
//         gc->addSelection("/13    255.248.0.0");
//         gc->addSelection("/14    255.252.0.0");
//         gc->addSelection("/15    255.254.0.0");
//         gc->addSelection("/16    255.255.0.0");
//         gc->addSelection("/17    255.255.128.0");
//         gc->addSelection("/18    255.255.192.0");
//         gc->addSelection("/19    255.255.224.0");
//         gc->addSelection("/20    255.255.240.0");
//         gc->addSelection("/21    255.255.248.0");
//         gc->addSelection("/22    255.255.252.0");
//         gc->addSelection("/23    255.255.254.0");
//         gc->addSelection("/24    255.255.255.0");
//         gc->addSelection("/25    255.255.255.128");
//         gc->addSelection("/26    255.255.255.192");
//         gc->addSelection("/27    255.255.255.224");
//         gc->addSelection("/28    255.255.255.240");
//         gc->addSelection("/29    255.255.255.248");
//         gc->addSelection("/30    255.255.255.252");
//         gc->addSelection("/31    255.255.255.254");
//         gc->addSelection("/32    255.255.255.255");
//         gc->setHelpText(QObject::tr("Netmask"));
//         gc->setValue(24);
//     return gc;
// };


QString findnet()
{

QString netdev="";
//QString netdev="eth0 eth1 wlan0 wlan1 ath0 ";
//QString netdev="eth0 eth1";
system("/sbin/ifconfig -a > /tmp/.netinfo");
QString line;
QFile file("/tmp/.netinfo");
    if ( file.open(IO_ReadOnly | IO_Translate) )
    {
        QTextStream t( &file );        // use a text stream
        while ( !t.eof() )
        {
            line = t.readLine();
            if ( line.contains("HWaddr"))
                {
                    QString s = line.simplifyWhiteSpace();
                    s = s.section( " ", 0, 0 );   // s == "surname"
                    netdev+=s;
                    netdev+=" ";
                }
        }
        file.close();
    }
return netdev;
}

QString findnet_wireless()
{

QString netdev="";
//QString netdev="eth0 eth1 wlan0 wlan1 ath0 ";
system("/usr/sbin/iwconfig  > /tmp/.netinfo_wireless");
QString line;
QFile file("/tmp/.netinfo_wireless");
    if ( file.open(IO_ReadOnly | IO_Translate) )
    {
        QTextStream t( &file );        // use a text stream
        while ( !t.eof() )
        {
            line = t.readLine();
            if ( line.contains("Nickname") || line.contains("ESSID"))
                {
                    QString s = line.simplifyWhiteSpace();
                    s = s.section( " ", 0, 0 );   // s == "surname"
                    netdev+=s;
                    netdev+=" ";
                }
        }
        file.close();
    }
return netdev;
}

static HostComboBox *HostNetDevice()
{
    HostComboBox *gc = new HostComboBox("HostNetDevice");
    gc->setLabel(QObject::tr("Device"));
    QString foundnet=findnet();
    cout << foundnet << endl;

    if (foundnet.contains(hostparm.ThisHostnetOLD))
        {
//             cout << "old setting is still active" << endl;
//             cout << hostparm.ThisHostnetOLD << endl;
            QString s = "HostActiveonboot";
            s+=hostparm.ThisHostnetOLD;
            gContext->SaveSetting(s, hostparm.ThisHostnetActiveOLD );
        }

    if (foundnet.contains("eth0"))
        gc->addSelection("eth0");

    if (foundnet.contains("eth1"))
        gc->addSelection("eth1");

    if (foundnet.contains("wlan0"))
        gc->addSelection("wlan0");

    if (foundnet.contains("wlan1"))
        gc->addSelection("wlan1");

    if (foundnet.contains("ath0"))
        gc->addSelection("ath0");

    int findoldnetdevice=gc->findSelection(hostparm.ThisHostnetOLD);
    gc->setValue(findoldnetdevice);



    gc->setHelpText(QObject::tr("Network interface"));
    return gc;
};

// static HostLineEdit *HostGW()
// {
//     HostLineEdit *gc = new HostLineEdit("HostGW");
//     gc->setLabel(QObject::tr("Gateway"));
//     gc->setValue("192.168.1.1");
//     gc->setHelpText(QObject::tr("This is the default route"));
//     return gc;
// };
//
// static HostLineEdit *HostDNS()
// {
//     HostLineEdit *gc = new HostLineEdit("HostDNS");
//     gc->setLabel(QObject::tr("Name server"));
//     gc->setValue("192.168.1.1");
//     gc->setHelpText(QObject::tr("Name server"));
//     return gc;
// };

static HostCheckBox *HostActiveonboot()
{
    HostCheckBox *gc = new HostCheckBox("HostActiveonboot");
    gc->setLabel(QObject::tr("Device is active on boot"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Network is started on boot"));
    return gc;
};


static HostCheckBox *HostServiceSamba()
{
    HostCheckBox *gc = new HostCheckBox("HostServiceSamba");
    gc->setLabel(QObject::tr("Windows sharing"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Allow window machines to access recorded files"));
    return gc;
};

static HostCheckBox *HostServiceSamba_write()
{
    HostCheckBox *gc = new HostCheckBox("HostServiceSamba_write");
    gc->setLabel(QObject::tr("Readonly"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("If checked, all remote connections will be read only.  If not checked then remote clients will have write and delete abilites. "));
    return gc;
};


static HostCheckBox *HostServiceSamba_writehome()
{
    HostCheckBox *gc = new HostCheckBox("HostServiceSamba_writehome");
    gc->setLabel(QObject::tr("Readonly"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("If checked, all remote connections will be read only.  If not checked then remote clients will have write and delete abilites. "));
    return gc;
};

static HostCheckBox *HostServiceSamba_media()
{
    HostCheckBox *gc = new HostCheckBox("HostServiceSamba_media");
    gc->setLabel(QObject::tr("share media"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr(" "));
    return gc;
};

static HostCheckBox *HostServiceSamba_home()
{
    HostCheckBox *gc = new HostCheckBox("HostServiceSamba_home");
    gc->setLabel(QObject::tr("share home"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr(" "));
    return gc;
};



static HostComboBox *HostServiceSamba_domain()
{
    HostComboBox *gc = new HostComboBox("HostServiceSamba_domain",true);
    gc->setLabel(QObject::tr("Workgroup"));
    gc->setHelpText(QObject::tr("Workgroup for smb share"));
    gc->addSelection("WORKGROUP");
    QString currentitem;
    QString line;
    QFile file("/tmp/smbdomainlist");
    if ( file.open(IO_ReadOnly | IO_Translate) )
    {
        QTextStream t( &file );        // use a text stream
        while ( !t.eof() )
        {
            line = t.readLine();
            if ( line.startsWith("domain"))
                {
                currentitem = line.section( " ", 1, 1 );
                if ( currentitem != "-" )
                    gc->addSelection(currentitem);
                }
        }
        file.close();
    }
    gc->addSelection("type_workgroup_here");
    return gc;
};

static HostCheckBox *HostLircWait()
{
    HostCheckBox *gc = new HostCheckBox("HostLircWait");
    gc->setLabel(QObject::tr("Wait for lirc"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("System will wait for lirc before starting the UI "));
    return gc;
};


static HostComboBox *HostEvrouterConfig()
{
    HostComboBox *gc = new HostComboBox("HostEvrouterConfig",true);
    gc->setLabel(QObject::tr("Layout"));
    gc->setHelpText(QObject::tr("Choose the keypad layout"));
    QString dirtxt;
    dirtxt=MV_ROOT;
    dirtxt.append("templates/evrouter");
    QDir evrouter(dirtxt);
    //evrouter.setFilter(QDir::Dirs);
    evrouter.setSorting(QDir::Name | QDir::IgnoreCase);
    const QFileInfoList *infos = evrouter.entryInfoList();
    const QFileInfo *info;
    if (!infos)
        return gc;
    QFileInfoListIterator infoIt( *infos );
    QString currentitem = ".";
    while( (info=infoIt.current()) != 0 )
    {
        currentitem = info->baseName( TRUE );
        if ( currentitem != ".." && currentitem != "." && currentitem != "")
        {
            gc->addSelection(currentitem);
        }
        ++infoIt;
    }
    gc->addSelection("tinker");
    return gc;
};


static HostCheckBox *HostServiceNFS()
{
    HostCheckBox *gc = new HostCheckBox("HostServiceNFS");
    gc->setLabel(QObject::tr("Standard file sharing"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Allow all machines to access recorded files with nfs"));
    return gc;
};


static HostCheckBox *HostServiceMythWEB()
{
    HostCheckBox *gc = new HostCheckBox("HostServiceMythWEB");
    gc->setLabel(QObject::tr("Enable Mythweb"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Allow scheduling using a web browser"));
    return gc;
};

static HostCheckBox *HostServiceHobbitclient()
{
    HostCheckBox *gc = new HostCheckBox("HostServiceHobbitclient");
    gc->setLabel(QObject::tr("Hobbit-client"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Report stats and other stuff to the master backend"));
    return gc;
};

static GlobalCheckBox *GlobalServiceHobbitserver()
{
    GlobalCheckBox *gc = new GlobalCheckBox("GlobalServiceHobbitserver");
    gc->setLabel(QObject::tr("Hobbit-server"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Run the hobbit server to collect stats and other stuff"));
    return gc;
};


static HostCheckBox *HostServiceRRD()
{
    HostCheckBox *gc = new HostCheckBox("HostServiceRRD");
    gc->setLabel(QObject::tr("rrd_stats"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Collect stats and create graphs of various system resources."));
    return gc;
};

static HostCheckBox *HostUseDHCP()
{
    HostCheckBox *gc = new HostCheckBox("HostUseDHCP");
    gc->setLabel(QObject::tr("Static ip address"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Enable to use a static ip address, otherwise dhcp will be used."));
    return gc;
};

static HostCheckBox *HostRunDHCP()
{
    HostCheckBox *gc = new HostCheckBox("HostRunDHCP");
    gc->setLabel(QObject::tr("DHCP server"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Check to run a dhcp server."));
    return gc;
};

static HostCheckBox *HostRunEvrouter()
{
    HostCheckBox *gc = new HostCheckBox("HostRunEvrouter");
    gc->setLabel(QObject::tr("Enable special keys"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Check if using evrouter"));
    return gc;
};

static HostCheckBox *HostUsemythfrontend()
{
    HostCheckBox *gc = new HostCheckBox("HostUseMythWelcome");
    gc->setLabel(QObject::tr("Run MythWelcome"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("If this option is checked mythwelcome will be started, instead of the usual frontend"));
    return gc;
};

static HostCheckBox *HostRunFrontend()
{
    HostCheckBox *gc = new HostCheckBox("HostRunFrontend");
    gc->setLabel(QObject::tr("Run the Frontend."));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("If this option is checked mythfrontend will also start"));
    return gc;
};


/*
static HostComboBox *HostTransmitproto()
{
    HostComboBox *gc = new HostComboBox("HostTransmitproto",false);
    gc->setLabel(QObject::tr("Transmitter"));
    gc->addSelection("none");
    gc->setValue(0);
    gc->setHelpText(QObject::tr("Remote codes to control a cable box"));
    QString dirtxt;
    dirtxt=MV_ROOT;
    dirtxt.append("templates/transmit");
    QDir transmit(dirtxt);
    transmit.setFilter(QDir::Dirs);
    transmit.setSorting(QDir::Name | QDir::IgnoreCase);
    const QFileInfoList *infos = transmit.entryInfoList();
    const QFileInfo *info;
    if (!infos)
        return gc;
    QFileInfoListIterator infoIt( *infos );
    QString currentitem = ".";
    while( (info=infoIt.current()) != 0 )
    {
        currentitem = info->baseName( TRUE );
        if ( currentitem != ".." && currentitem != "." && currentitem != "")
        {
            gc->addSelection(currentitem);
        }
        ++infoIt;
    }
    return gc;
};



static HostComboBox *HostReceiverType()
{
    HostComboBox *gc = new HostComboBox("HostReceiverType");
    gc->setLabel(QObject::tr("Receiver"));
    gc->addSelection("Default");
    gc->addSelection("Serial");
    gc->addSelection("Usb");
    gc->addSelection("Usb-imon");
    gc->addSelection("Hauppauge");
    gc->addSelection("tinker");
    gc->setHelpText(QObject::tr("The type of infrared receiver and transmitter being used."));
    gc->setValue("Default");
    return gc;
};

static HostComboBox *HostSerialPortlirc()
{
    HostComboBox *gc = new HostComboBox("HostSerialPortlirc",false);
    gc->setLabel(QObject::tr("Serial Port"));
    gc->addSelection("ttyS0");
    gc->addSelection("ttyS1");
    gc->addSelection("ttyS2");
    gc->addSelection("ttyS3");
    gc->setHelpText(QObject::tr("Serial port with the lirc receiver or transmitter"));
    return gc;
}

*/

static HostComboBox *HostMysqlserverip_listbox()
{
    HostComboBox *gc = new HostComboBox("HostMysqlServer",true);
    gc->setLabel(QObject::tr("Mysql server"));

    QString currentitem;
    QString prevline;
    QString line;
    QFile file("/tmp/mysqllist");
        if ( file.open(IO_ReadOnly | IO_Translate) )
        {
        QTextStream t( &file );        // use a text stream
        while ( !t.eof() )
            {
            line = t.readLine();
            if ( line.startsWith("   address"))
                {
                currentitem = line.section( " ", 5, 5 );
                currentitem = currentitem.section( "[" , 1,1 );
                currentitem = currentitem.section( "]" , 0, 0 );

                currentitem = currentitem + "\t" +  prevline.section( " ",5,5  );
                //cout << currentitem  << endl;
                gc->addSelection(currentitem);
                }
                prevline = line;
                }
            file.close();
            //system ("rm -f /tmp/mysqllist");
        }
    gc->addSelection("Manual: type ip here");
    gc->setHelpText(QObject::tr(""));

    QString NETBOOT = getenv("NETBOOT");
    NETBOOT=NETBOOT.stripWhiteSpace();
    if ( NETBOOT   != "YES" )
    {
        if ( ((gContext->GetSetting("HostaccesshostypeSystemtype")) == "0" ))
            gc->setEnabled(false);
    }

    return gc;
}



static HostCheckBox *HostRemoteBackup()
{
    HostCheckBox *gc = new HostCheckBox("HostRemoteBackup");
    gc->setLabel(QObject::tr("Remote Backup"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Copy the resulting backup file to another location"));
    return gc;
};


static HostComboBox *HostRemoteBackupDir()
{
    QString tempItem;
    HostComboBox *gc = new HostComboBox("HostRemoteBackupDir",true);
    gc->setLabel(QObject::tr("dir or host" ));
    gc->addSelection("dir:/localdir");
    MSqlQuery query(MSqlQuery::InitCon());


    query.prepare( "SELECT DISTINCT hostname from settings where hostname is not null and not (hostname=:HOSTNAME);");
    query.bindValue( ":HOSTNAME" ,   gContext->GetHostName()  );
    if (query.exec() && query.isActive() && query.size() > 0)
    {
        while (query.next())
        {
            tempItem = query.value(0).toString();
            gc->addSelection(tempItem);
        }
    }

    gc->setHelpText(QObject::tr("Host to copy backup file to.   dir:/$localdir   will copy to a local directory instead of a remote host "));

    return gc;
};

class Backupsettings: public TriggeredConfigurationGroup {
public:
    Backupsettings():
        TriggeredConfigurationGroup(false, false, true, true,false, false, true, true) {
        SetVertical(false);
        setLabel(QObject::tr("Backup Settings"));
        Setting* trigger = HostRemoteBackup();
        addChild(trigger);
        setTrigger(trigger);
        ConfigurationGroup* settings = new VerticalConfigurationGroup(false,false);
            settings->addChild(HostRemoteBackupDir());

        addTarget("0", new VerticalConfigurationGroup(false, false));
        addTarget("1", settings);

    };
};



static HostCheckBox *HostPKG_MIRROR()
{
    HostCheckBox *gc = new HostCheckBox("HostPKG_MIRROR");
    gc->setLabel(QObject::tr("Use Local mirror"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Master Backend will be used as the repo source."));
    return gc;
};

static GlobalCheckBox *GlobalPKG_MIRROR()
{
    GlobalCheckBox *gc = new GlobalCheckBox("GlobalPKG_MIRROR");
    gc->setLabel(QObject::tr("Local mirror"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Keep a local copy of the packages.  Allow other frontends to install from the local copy."));
    return gc;
};



static HostCheckBox *HostncidClient()
{
    HostCheckBox *gc = new HostCheckBox("HostncidClient");
    gc->setLabel(QObject::tr("Show Callerid"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Callerid popup,  backend must be running the callerid program"));
    return gc;
};

static HostCheckBox *HostncidDaemon()
{
    HostCheckBox *gc = new HostCheckBox("HostncidDaemon");
    gc->setLabel(QObject::tr("Run Callerid "));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Run Daemon to collect callerid info"));
    return gc;
};

static HostComboBox *HostSerialPortncid()
{
    HostComboBox *gc = new HostComboBox("HostSerialPortncid",false);
    gc->setLabel(QObject::tr("Serial Port"));
    gc->addSelection("ttyS0");
    gc->addSelection("ttyS1");
    gc->addSelection("ttyS2");
    gc->addSelection("ttyS3");
    gc->setHelpText(QObject::tr("Serial port where callerid capable modem is connected"));
    return gc;
}

static HostCheckBox *Hostbootsplash()
{
    HostCheckBox *gc = new HostCheckBox("Hostbootsplash");
    gc->setLabel(QObject::tr("Enable bootsplash"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Covers up boot messages. "));
    return gc;
};

//-------------------------------------screensaver settings-------------------

static HostComboBox *HostScreensaverType()
{
    HostComboBox *gc = new HostComboBox("HostScreensaverType");
    gc->setLabel(QObject::tr("Screensaver program"));
    gc->addSelection("xscreensaver");
    gc->addSelection("gscreensaver");
    gc->addSelection("none");
    gc->addSelection("tinker");
    gc->setHelpText(QObject::tr("Screen saver program to use."));
    gc->setValue("none");
    return gc;
};

static HostSpinBox *HostScreensaverIdle()
{
    HostSpinBox *gc = new HostSpinBox("HostScreensaverIdle", 5, 60, 1, true);
    gc->setLabel(QObject::tr("Idle time"));
    gc->setValue(5);
    gc->setHelpText(QObject::tr("Number of minutes to wait before starting screensaver."  ));
    return gc;
}

static HostCheckBox *HostScreensaverBlank()
{
    HostCheckBox *gc = new HostCheckBox("HostScreensaverBlank");
    gc->setLabel(QObject::tr("Blank"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Blank the screen instead of using a screensaver"));
    return gc;
};

static HostCheckBox *HostScreensaverRandom()
{
    HostCheckBox *gc = new HostCheckBox("HostScreensaverRandom");
    gc->setLabel(QObject::tr("Random"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Use a random screensaver"));
    return gc;
};



static HostComboBox *HostGScreensaverTheme()
{
    HostComboBox *gc = new HostComboBox("HostGScreensaverTheme");
    gc->setLabel(QObject::tr("Screensaver"));
    gc->setHelpText(QObject::tr("Screen saver program to use."));
    QString line;
    QString dirtxt=MV_ROOT;
    dirtxt.append("templates/gscreensavers");
    QFile file(dirtxt);
    if ( file.open(IO_ReadOnly | IO_Translate) )
    {
        QTextStream t( &file );        // use a text stream
        while ( !t.eof() )
        {
            line = t.readLine();
             gc->addSelection(line);
        }
        file.close();
    }
    return gc;
};

static HostComboBox *HostXScreensaverTheme()
{
    HostComboBox *gc = new HostComboBox("HostXScreensaverTheme");
    gc->setLabel(QObject::tr("Screensaver"));
    gc->setHelpText(QObject::tr("Screen saver to display."));
    QString dirtxt;
    dirtxt=MV_ROOT;
    dirtxt.append("templates/xscreensavers");
    //read in from a file.
    QString line;
    QFile file(dirtxt);
    if ( file.open(IO_ReadOnly | IO_Translate) )
    {
        QTextStream t( &file );        // use a text stream
        while ( !t.eof() )
        {
            line = t.readLine();
             gc->addSelection(line);
        }
        file.close();
    }
    return gc;
};

class Screensaverhostsettings: public TriggeredConfigurationGroup {
public:
    Screensaverhostsettings():

        TriggeredConfigurationGroup() {
        SetVertical(true);
        setLabel(QObject::tr("Screensaver settings (1/1)"));
        Setting* trigger = HostScreensaverType() ;
        addChild(trigger);
        setTrigger(trigger);
        ConfigurationGroup* screensaversettings = new GridConfigurationGroup(2);
            screensaversettings->addChild(HostScreensaverBlank());
            screensaversettings->addChild(HostScreensaverRandom());

        ConfigurationGroup* xscreensaversettings = new VerticalConfigurationGroup();
            xscreensaversettings->addChild(screensaversettings);
            xscreensaversettings->addChild(HostScreensaverIdle());
            xscreensaversettings->addChild(HostXScreensaverTheme());


        ConfigurationGroup* gscreensaversettings = new VerticalConfigurationGroup();
            gscreensaversettings->addChild(screensaversettings);
            gscreensaversettings->addChild(HostScreensaverIdle());
            gscreensaversettings->addChild(HostGScreensaverTheme());



        addTarget("tinker", new VerticalConfigurationGroup(false, false));
        addTarget("none", new VerticalConfigurationGroup(false, false));
        addTarget("gscreensaver", gscreensaversettings);
        addTarget("xscreensaver", xscreensaversettings);
    };
};




//-------------------------------------access setting----------------------

static HostCheckBox *Hostaccessnetwork()
{
    HostCheckBox *gc = new HostCheckBox("Hostaccessnetwork");
    gc->setLabel(QObject::tr("Network "));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Control access to network screen. Checked means the screen is enabled."));
    return gc;
};

static HostCheckBox *Hostaccesshostype()
{
    HostCheckBox *gc = new HostCheckBox("Hostaccesshostype");
    gc->setLabel(QObject::tr("hostype "));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Control access to hostype screen. Checked means the screen is enabled."));
    return gc;
};

static HostCheckBox *HostaccesshostypeSystemtype()
{
    HostCheckBox *gc = new HostCheckBox("HostaccesshostypeSystemtype");
    gc->setLabel(QObject::tr("Change hostype"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Ability to change sql server and system type. Checked means the screen is enabled."));
    return gc;
};

static HostCheckBox *Hostaccessmisc()
{
    HostCheckBox *gc = new HostCheckBox("Hostaccessmisc");
    gc->setLabel(QObject::tr("misc "));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Control access to misc screen. Checked means the screen is enabled."));
    return gc;
};

static HostCheckBox *Hostaccesssleep()
{
    HostCheckBox *gc = new HostCheckBox("Hostaccesssleep");
    gc->setLabel(QObject::tr("sleep "));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Control access to sleep screen. Checked means the screen is enabled."));
    return gc;
};

static HostCheckBox *Hostaccessadvanced()
{
    HostCheckBox *gc = new HostCheckBox("Hostaccessadvanced");
    gc->setLabel(QObject::tr("advanced "));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Control access to advanced screen. Checked means the screen is enabled. "));
    return gc;
};

static HostCheckBox *HostaccessadvancedX()
{
    HostCheckBox *gc = new HostCheckBox("HostaccessadvancedX");
    gc->setLabel(QObject::tr("advancedX "));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Control access to advancedX screen. Checked means the screen is enabled. "));
    return gc;
};
static HostCheckBox *Hostaccesssound()
{
    HostCheckBox *gc = new HostCheckBox("Hostaccesssound");
    gc->setLabel(QObject::tr("sound "));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Control access to sound screen. Checked means the screen is enabled."));
    return gc;
};

static HostCheckBox *Hostaccessplugins()
{
    HostCheckBox *gc = new HostCheckBox("Hostaccessplugins");
    gc->setLabel(QObject::tr("plugins"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Control access to plugin screen. Checked means the screen is enabled."));
    return gc;
};

static HostCheckBox *Hostaccessuser()
{
    HostCheckBox *gc = new HostCheckBox("Hostaccessuser");
    gc->setLabel(QObject::tr("User"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Control access to the user managment screen. Checked means the screen is enabled."));
    return gc;
};

static HostCheckBox *Hostaccesswebuser()
{
    HostCheckBox *gc = new HostCheckBox("Hostaccesswebuser");
    gc->setLabel(QObject::tr("Web password"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Control access to the web password screen. Checked means the screen is enabled."));
    return gc;
};


class ACCESShostsettings: public TriggeredConfigurationGroup {
public:
    ACCESShostsettings():
        TriggeredConfigurationGroup(false,false,false,false) {
        SetVertical(false);
        Setting* trigger = Hostaccesshostype () ;
        addChild(trigger);
        setTrigger(trigger);

        ConfigurationGroup* settings = new VerticalConfigurationGroup(false,false,false,false);
                //settings->addChild(HostServiceSamba());
                settings->addChild(HostaccesshostypeSystemtype());


        addTarget("0", new VerticalConfigurationGroup(false, false));
        addTarget("1", settings);
    };
};


//----------------------------------  PLUGINS ----------------------

static HostCheckBox *Hostpluginmytharchive()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmytharchive");
    gc->setLabel(QObject::tr("mytharchive"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("check to enable mytharchive"));
    return gc;
};


static HostCheckBox *Hostpluginmythbrowser()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythbrowser");
    gc->setLabel(QObject::tr("mythbrowser"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("check to enable mythbrowser"));
    return gc;
};


static HostCheckBox *Hostpluginmythcontrols()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythcontrols");
    gc->setLabel(QObject::tr("mythcontrols"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("check to enable mythcontrols"));
    return gc;
};


static HostCheckBox *Hostpluginmythflix()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythflix");
    gc->setLabel(QObject::tr("mythflix"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("check to enable mythflix"));
    return gc;
};


static HostCheckBox *Hostpluginmythgallery()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythgallery");
    gc->setLabel(QObject::tr("mythgallery"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("check to enable mythgallery"));
    return gc;
};


static HostCheckBox *Hostpluginmythgame()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythgame");
    gc->setLabel(QObject::tr("mythgame"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("check to enable mythgame"));
    return gc;
};

static HostCheckBox *HostpluginmythgameZsnes()
{
    HostCheckBox *gc = new HostCheckBox("HostpluginmythgameZsnes");
    gc->setLabel(QObject::tr("zsnes"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Zsnes, super nintendo emulator"));
    return gc;
};

static HostCheckBox *HostpluginmythgameFceu()
{
    HostCheckBox *gc = new HostCheckBox("HostpluginmythgameFceu");
    gc->setLabel(QObject::tr("fceu"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Fceu, nintendo emulator"));
    return gc;
};

static HostCheckBox *HostpluginmythgameMame()
{
    HostCheckBox *gc = new HostCheckBox("HostpluginmythgameMame");
    gc->setLabel(QObject::tr("mame"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Mame, Multiple Arcade Machine Emulator."));
    return gc;
};

static HostCheckBox *HostpluginmythgameMednafen()
{
    HostCheckBox *gc = new HostCheckBox("HostpluginmythgameMednafen");
    gc->setLabel(QObject::tr("Mednafen"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Mednafen is a portable, utilizing OpenGL and SDL, command-line driven multi-system emulator with many advanced features."));
    return gc;
};

static HostCheckBox *HostpluginmythgameROMDB()
{
    HostCheckBox *gc = new HostCheckBox("HostpluginmythgameROMDB");
    gc->setLabel(QObject::tr("Romdb"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Table used my MythGames to store information about games. If you are into games, this is recommended."));
    return gc;
};


static HostCheckBox *Hostpluginmythmovietime()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythmovietime");
    gc->setLabel(QObject::tr("mythmovietime"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Check to enable mythmovietime"));
    return gc;
};


static HostCheckBox *Hostpluginmythmusic()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythmusic");
    gc->setLabel(QObject::tr("mythmusic"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("check to enable mythmusic"));
    return gc;
};


static HostCheckBox *Hostpluginmythnews()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythnews");
    gc->setLabel(QObject::tr("mythnews"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("check to enable mythnews"));
    return gc;
};


static HostCheckBox *Hostpluginmythphone()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythphone");
    gc->setLabel(QObject::tr("mythphone"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("check to enable mythphone"));
    return gc;
};


static HostCheckBox *Hostpluginmythsmolt()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythsmolt");
    gc->setLabel(QObject::tr("mythsmolt"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("check to enable mythsmolt"));
    return gc;
};


static HostCheckBox *Hostpluginmythvideo()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythvideo");
    gc->setLabel(QObject::tr("mythvideo"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("check to enable mythvideo"));
    return gc;
};

static HostCheckBox *Hostpluginmythvideo_dvdcss()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythvideo_dvdcss");
    gc->setLabel(QObject::tr("dvdcss"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("libdvdcss is a simple library designed for accessing DVDs like a block device without having to bother about the decryption."));
    return gc;
};


static HostCheckBox *Hostpluginmythvodka()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythvodka");
    gc->setLabel(QObject::tr("mythvodka"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Myth Video On Demand Killer App."));
    return gc;
};


static HostCheckBox *Hostpluginmythstream()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythstream");
    gc->setLabel(QObject::tr("mythstream"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("MythStream is an unofficial MythTv plugin that plays Internet audio and video streams."));
    return gc;
};

static HostCheckBox *Hostpluginmythappletrailers()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythappletrailers");
    gc->setLabel(QObject::tr("MythAppleTrailers"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Used to stream trailer's from Apple's website."));
    return gc;
};


static HostCheckBox *Hostpluginmythweather()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythweather");
    gc->setLabel(QObject::tr("mythweather"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("check to enable mythweather"));
    return gc;
};


static HostCheckBox *HostMiro()
{
    HostCheckBox *gc = new HostCheckBox("HostMiro");
    gc->setLabel(QObject::tr("Miro"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Miro is a popular, free, and open internet TV application. It brings video channels from thousands of sources and has more free HD than any otherplatform."));
    return gc;
};


static HostCheckBox *HostXine()
{
    HostCheckBox *gc = new HostCheckBox("HostXine");
    gc->setLabel(QObject::tr("Xine"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Xine is a free multimedia player"));
    return gc;
};


static HostCheckBox *Hostwebmin()
{
    HostCheckBox *gc = new HostCheckBox("Hostwebmin");
    gc->setLabel(QObject::tr("Webmin"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Webmin is a web-based interface for system  administration for Unix. Once installed, you can access it at https://ip.of.back.end:10000 using your root password."));
    return gc;
};

static HostCheckBox *Hostfuppes()
{
    HostCheckBox *gc = new HostCheckBox("Hostfuppes");
    gc->setLabel(QObject::tr("Fuppes"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Upnp server"));
    return gc;
};

static HostCheckBox *Hostfoldingathome()
{
    HostCheckBox *gc = new HostCheckBox("Hostfoldingathome");
    gc->setLabel(QObject::tr("Folding@home"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("A distributed computing project which studies protein folding, misfolding, aggregation, and related diseases."));
    return gc;
};

static HostComboBox *Hostfoldingusername()
{
    // If there is an old R5.5 style folding directory /myth/folding@home, attempt 
    // to retrieve the old username.
    
    FILE *username_pipe;
    username_pipe = 
      popen (
        "grep username= /myth/folding@home/client.cfg 2> /dev/null | "
        "sed 's/username=//g'", "r");

    if (username_pipe)
    {
      char username[200];
      if (fgets (username, sizeof (username), username_pipe))
      {
    	  char *new_line;
	  username[sizeof(username)-1]=0;
	  if ((new_line = strchr (username, '\n')))
	    new_line[0] = 0;

	  cout << "found old username " << username << endl;

    	  gContext->SetSetting("Hostfoldingusername", username);
    	  gContext->SaveSetting("Hostfoldingusername", username);
      }
      pclose (username_pipe);
    }

    HostComboBox *gc = new HostComboBox("Hostfoldingusername",true);
    gc->setLabel(QObject::tr("Folding Username"));
    gc->setValue("");

    gc->setHelpText(QObject::tr("The username associated to the work-units you return."));
    return gc;
};

static HostComboBox *Hostfoldingworksize()
{
    HostComboBox *gc = new HostComboBox("Hostfoldingworksize");
    gc->setLabel(QObject::tr("Work Packet Size"));
    gc->addSelection("Big", "big");
    gc->addSelection("Normal", "normal");
    gc->addSelection("Small", "small");
    gc->setHelpText(QObject::tr("Acceptable size of work assignment and work result packets (bigger units may have large memory demands)."));
    return gc;
};

static HostCheckBox *HostXscreensaver()
{
    HostCheckBox *gc = new HostCheckBox("HostXscreensaver");
    gc->setLabel(QObject::tr("Screensaver"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Run screensaver after 10 minutes of inactivity."));
    return gc;
};


static HostCheckBox *Hostpluginmythzoneminder()
{
    HostCheckBox *gc = new HostCheckBox("Hostpluginmythzoneminder");
    gc->setLabel(QObject::tr("mythzoneminder"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("check to enable mythzoneminder"));
    return gc;
};


// -------------End plugins--------------------------------



class NCIDsettings: public TriggeredConfigurationGroup {
public:
    NCIDsettings():
        TriggeredConfigurationGroup(false, false, true, true,false, false, true, true) {
        SetVertical(false);
        Setting* trigger =  HostncidDaemon() ;
        addChild(trigger);
        setTrigger(trigger);
        ConfigurationGroup* settings = new HorizontalConfigurationGroup(false,false);
            settings->addChild(HostSerialPortncid());
        addTarget("0", new HorizontalConfigurationGroup(false, false));
        addTarget("1", settings);
    };
};

class SAMBAsettings: public TriggeredConfigurationGroup {
public:
    SAMBAsettings():
        TriggeredConfigurationGroup(false, true, true, true,false, false, true, true) {
        SetVertical(false);
        Setting* trigger =  HostServiceSamba() ;
        addChild(trigger);
        setTrigger(trigger);

        ConfigurationGroup* settings = new GridConfigurationGroup(2,false,false);
                //settings->addChild(HostServiceSamba());
                settings->addChild(HostServiceSamba_media());
                settings->addChild(HostServiceSamba_write());
                settings->addChild(HostServiceSamba_home());
                settings->addChild(HostServiceSamba_writehome());
                settings->addChild(HostServiceSamba_domain());

        addTarget("0", new GridConfigurationGroup(2,false, false));
        addTarget("1", settings);
    };
};



/*
class LIRCsettings: public TriggeredConfigurationGroup {
public:
    LIRCsettings():
        TriggeredConfigurationGroup(false, false, true, true,false, false, true, true) {
        //SetVertical(false);
        setLabel(QObject::tr("Misc Settings"));
        Setting* trigger =  HostReceiverType() ;
        addChild(trigger);
        setTrigger(trigger);

        ConfigurationGroup* settings = new GridConfigurationGroup(2,true);
        settings->addChild(HostLircWait());
        settings->addChild(HostSerialPortlirc());

        ConfigurationGroup* settings2 = new VerticalConfigurationGroup(true,true);
        settings2->addChild(HostLircWait());

        addTarget("Default", settings2);
        addTarget("Serial", settings);
        addTarget("Usb", settings2);
        addTarget("Usb-imon", settings2 );
        addTarget("Hauppauge",settings2);
        addTarget("tinker", new VerticalConfigurationGroup(false, false));
    };
};*/

class Evroutersettings: public TriggeredConfigurationGroup {
    public:
    Evroutersettings():
        TriggeredConfigurationGroup(false, false, true, true,false, false, true, true) {
        //SetVertical(false);
        setLabel(QObject::tr("Evrouter config"));
        Setting* trigger =  HostRunEvrouter() ;
        addChild(trigger);
        setTrigger(trigger);

        ConfigurationGroup* settings = new VerticalConfigurationGroup(false,false);
        settings->addChild(HostEvrouterConfig());

        addTarget("0", new VerticalConfigurationGroup(false, false));
        addTarget("1", settings);
        };
};

class MythGamesettings: public TriggeredConfigurationGroup {
    public:
    MythGamesettings():
        TriggeredConfigurationGroup(false, false, true, true,false, false, true, true) {
        //SetVertical(false);
        //setLabel(QObject::tr("Evrouter config"));
        Setting* trigger =  Hostpluginmythgame() ;
        addChild(trigger);
        setTrigger(trigger);

        ConfigurationGroup* settings = new GridConfigurationGroup(3,true,true);
        settings->addChild(HostpluginmythgameZsnes());
        settings->addChild(HostpluginmythgameFceu());
        settings->addChild(HostpluginmythgameMame());
        settings->addChild(HostpluginmythgameMednafen());
        settings->addChild(HostpluginmythgameROMDB());


        addTarget("0", new VerticalConfigurationGroup(false, false));
        addTarget("1", settings);
        };
};


//____________________________________________________________________________
class eth0_settings:          public TriggeredConfigurationGroup {
public:
    eth0_settings():
    TriggeredConfigurationGroup(true,false,true,true,false,false,false,true) {

    HostComboBox *HOSTESSIDeth0 = new HostComboBox("HOSTESSIDeth0",true);
        HOSTESSIDeth0->setLabel(QObject::tr("ESSID"));
        HOSTESSIDeth0->addSelection("MythVantage");
        HOSTESSIDeth0->addSelection("home_lan");
        HOSTESSIDeth0->addSelection("type_it_here");
        HOSTESSIDeth0->setHelpText(QObject::tr("ESSID"));
    addChild(HOSTESSIDeth0);

    HostComboBox *HostUseEncryptioneth0 = new HostComboBox("HostUseEncryptioneth0");
        HostUseEncryptioneth0->setLabel(QObject::tr("Encryption"));
        HostUseEncryptioneth0->setHelpText(QObject::tr("WPA uses a shared key phrase this is the most secure.  For WEP use the generated key, this type of encryption is not recommended."));
        HostUseEncryptioneth0->addSelection("none");
        HostUseEncryptioneth0->addSelection("WPA");
        HostUseEncryptioneth0->addSelection("WEP");

    Setting*  HostUseEncryption =  HostUseEncryptioneth0;
        addChild(HostUseEncryption);
        setTrigger(HostUseEncryption);

    HostLineEdit *Hostkeyeth0 = new HostLineEdit("Hostkeyeth0");
        Hostkeyeth0->setLabel(QObject::tr("key"));
        Hostkeyeth0->setHelpText(QObject::tr("Key to use for encryption"));

    ConfigurationGroup* settings = new GridConfigurationGroup(1,false);
        settings->addChild(Hostkeyeth0);
    addTarget("none", new GridConfigurationGroup(1,false));
    addTarget("WPA", settings);
    addTarget("WEP", settings);
    };
};


NetworkSettingseth0::NetworkSettingseth0():
        TriggeredConfigurationGroup(false,false,false,false) {
        setLabel(QObject::tr("Network Settings"));
    HostLineEdit  *HostIPeth0 = new HostLineEdit("HostIPeth0");
    HostIPeth0->setLabel(QObject::tr("Ip address"));
    HostIPeth0->setValue("192.168.1.12");
    HostIPeth0->setHelpText(QObject::tr("IP address of the new installation"));

    HostComboBox *HostNETMASKeth0 = new HostComboBox("HostNETMASKeth0");
        HostNETMASKeth0->setLabel(QObject::tr("Netmask"));
        HostNETMASKeth0->addSelection("/0     0.0.0.0");
        HostNETMASKeth0->addSelection("/1     128.0.0.0");
        HostNETMASKeth0->addSelection("/2     192.0.0.0");
        HostNETMASKeth0->addSelection("/3     224.0.0.0");
        HostNETMASKeth0->addSelection("/4     240.0.0.0");
        HostNETMASKeth0->addSelection("/5     248.0.0.0");
        HostNETMASKeth0->addSelection("/6     252.0.0.0");
        HostNETMASKeth0->addSelection("/7     254.0.0.0");
        HostNETMASKeth0->addSelection("/8     255.0.0.0");
        HostNETMASKeth0->addSelection("/9     255.128.0.0");
        HostNETMASKeth0->addSelection("/10    255.192.0.0 ");
        HostNETMASKeth0->addSelection("/11    255.224.0.0");
        HostNETMASKeth0->addSelection("/12    255.240.0.0");
        HostNETMASKeth0->addSelection("/13    255.248.0.0");
        HostNETMASKeth0->addSelection("/14    255.252.0.0");
        HostNETMASKeth0->addSelection("/15    255.254.0.0");
        HostNETMASKeth0->addSelection("/16    255.255.0.0");
        HostNETMASKeth0->addSelection("/17    255.255.128.0");
        HostNETMASKeth0->addSelection("/18    255.255.192.0");
        HostNETMASKeth0->addSelection("/19    255.255.224.0");
        HostNETMASKeth0->addSelection("/20    255.255.240.0");
        HostNETMASKeth0->addSelection("/21    255.255.248.0");
        HostNETMASKeth0->addSelection("/22    255.255.252.0");
        HostNETMASKeth0->addSelection("/23    255.255.254.0");
        HostNETMASKeth0->addSelection("/24    255.255.255.0");
        HostNETMASKeth0->addSelection("/25    255.255.255.128");
        HostNETMASKeth0->addSelection("/26    255.255.255.192");
        HostNETMASKeth0->addSelection("/27    255.255.255.224");
        HostNETMASKeth0->addSelection("/28    255.255.255.240");
        HostNETMASKeth0->addSelection("/29    255.255.255.248");
        HostNETMASKeth0->addSelection("/30    255.255.255.252");
        HostNETMASKeth0->addSelection("/31    255.255.255.254");
        HostNETMASKeth0->addSelection("/32    255.255.255.255");
        HostNETMASKeth0->setHelpText(QObject::tr("Netmask"));
        HostNETMASKeth0->setValue(24);

        HostLineEdit *HostGWeth0 = new HostLineEdit("HostGWeth0");
        HostGWeth0->setLabel(QObject::tr("Gateway"));
        HostGWeth0->setValue("192.168.1.1");
        HostGWeth0->setHelpText(QObject::tr("This is the default route"));


        HostLineEdit *HostDNSeth0 = new HostLineEdit("HostDNSeth0");
        HostDNSeth0->setLabel(QObject::tr("Name server"));
        HostDNSeth0->setValue("192.168.1.1");
        HostDNSeth0->setHelpText(QObject::tr("Name server"));


        HostCheckBox *HostActiveonbooteth0 = new HostCheckBox("HostActiveonbooteth0");
        HostActiveonbooteth0->setLabel(QObject::tr("Active"));
        HostActiveonbooteth0->setValue(true);
        HostActiveonbooteth0->setHelpText(QObject::tr("Network is started on boot"));

        HostDefaulteth0 = new HostCheckBox("HostDefaulteth0");
        HostDefaulteth0->setLabel(QObject::tr("Default"));
        HostDefaulteth0->setValue(true);
        HostDefaulteth0->setHelpText(QObject::tr("Will be used as the primary interface"));
        connect(HostDefaulteth0, SIGNAL(valueChanged(bool)), this, SLOT(eth0_disable_others()));

        HostCheckBox *HostUseDHCPeth0 = new HostCheckBox("HostUseDHCPeth0");
        HostUseDHCPeth0 ->setLabel(QObject::tr("Static ip address"));
        HostUseDHCPeth0 ->setValue(false);
        HostUseDHCPeth0 ->setHelpText(QObject::tr("Enable to use a static ip address, otherwise dhcp will be used."));

        wirelessbuttoneth0 = new TransButtonSetting();
        wirelessbuttoneth0->setLabel(tr("Wireless Settings"));
        connect(wirelessbuttoneth0, SIGNAL(pressed()), this,   SLOT(eth0_wireless_settings()));

      ConfigurationGroup* settings1 = new GridConfigurationGroup(3,false, false, true, true);
            settings1->addChild(HostActiveonbooteth0);
            settings1->addChild(HostDefaulteth0);
            settings1-> addChild(wirelessbuttoneth0);
        addChild(settings1);


        Setting* dhcpEnabled = HostUseDHCPeth0;
        addChild(dhcpEnabled);
        setTrigger(dhcpEnabled);

        ConfigurationGroup* settings = new VerticalConfigurationGroup(false, false, false, false);
            settings->addChild(HostIPeth0);
            settings->addChild(HostNETMASKeth0);
            settings->addChild(HostGWeth0);
            settings->addChild(HostDNSeth0);

        addTarget("0", new VerticalConfigurationGroup(false,false,false,false));
        addTarget("1", settings);
    };

eth0options::eth0options()
{

    VerticalConfigurationGroup* rec = new VerticalConfigurationGroup(false);
    rec->setLabel(QObject::tr("Wireless configuration for eth0"));
    //rec->setUseLabel(true);
    rec->addChild(new eth0_settings);
    addChild(rec);
}

void NetworkSettingseth0::eth0_disable_others()
{
        QString my_current_value;
        my_current_value = HostDefaulteth0->getValue();
        if ( my_current_value == "1" )
        {
            cout <<"ETH0: set other defaults buttons to off"<<endl;
        hostparm.ThisHostDefaultInterface="eth0";
            emit eth0_is_default();
        }
}
void NetworkSettingseth0::eth0_disabled()
{
    cout << "    eth0 is not default" << endl;
    HostDefaulteth0->setValue(0);
}
void NetworkSettingseth0::eth0_wireless_settings(void)
{
    //cout <<"button pressed for eth0"<<endl;
    eth0options eth0screen;
    eth0screen.exec();
}

void NetworkSettingseth0::eth0_wireless_disable()
{
    cout << "    eth0 disabling wireless button" << endl;
    wirelessbuttoneth0->setEnabled(false);
}

class eth1_settings:          public TriggeredConfigurationGroup {
public:
    eth1_settings():
    TriggeredConfigurationGroup(true,false,true,true,false,false,false,true) {

    HostComboBox *HOSTESSIDeth1 = new HostComboBox("HOSTESSIDeth1",true);
        HOSTESSIDeth1->setLabel(QObject::tr("ESSID"));
        HOSTESSIDeth1->addSelection("MythVantage");
        HOSTESSIDeth1->addSelection("home_lan");
        HOSTESSIDeth1->addSelection("type_it_here");
        HOSTESSIDeth1->setHelpText(QObject::tr("ESSID"));
    addChild(HOSTESSIDeth1);
    HostComboBox *HostUseEncryptioneth0 = new HostComboBox("HostUseEncryptioneth0");
        HostUseEncryptioneth0->setLabel(QObject::tr("Encryption"));
        HostUseEncryptioneth0->setHelpText(QObject::tr("WPA, WEP, none"));
        HostUseEncryptioneth0->addSelection("none");
        HostUseEncryptioneth0->addSelection("WPA");
        HostUseEncryptioneth0->addSelection("WEP");

    Setting*  HostUseEncryption =  HostUseEncryptioneth0;
        addChild(HostUseEncryption);
        setTrigger(HostUseEncryption);

    HostLineEdit *Hostkeyeth0 = new HostLineEdit("Hostkeyeth0");
        Hostkeyeth0->setLabel(QObject::tr("key"));
        Hostkeyeth0->setHelpText(QObject::tr("Key to use for encryption"));

    ConfigurationGroup* settings = new GridConfigurationGroup(1,false);
        settings->addChild(Hostkeyeth0);
    addTarget("none", new GridConfigurationGroup(1,false));
    addTarget("WPA", settings);
    addTarget("WEP", settings);
    //-


    };
};


NetworkSettingseth1::NetworkSettingseth1():
        TriggeredConfigurationGroup(false,false,false,false) {
    setLabel(QObject::tr("Network Settings"));
    HostLineEdit  *HostIPeth1 = new HostLineEdit("HostIPeth1");
    HostIPeth1->setLabel(QObject::tr("Ip address"));
    HostIPeth1->setValue("192.168.1.12");
    HostIPeth1->setHelpText(QObject::tr("IP address of the new installation"));

    HostComboBox *HostNETMASKeth1 = new HostComboBox("HostNETMASKeth1");
        HostNETMASKeth1->setLabel(QObject::tr("Netmask"));
        HostNETMASKeth1->addSelection("/0     0.0.0.0");
        HostNETMASKeth1->addSelection("/1     128.0.0.0");
        HostNETMASKeth1->addSelection("/2     192.0.0.0");
        HostNETMASKeth1->addSelection("/3     224.0.0.0");
        HostNETMASKeth1->addSelection("/4     240.0.0.0");
        HostNETMASKeth1->addSelection("/5     248.0.0.0");
        HostNETMASKeth1->addSelection("/6     252.0.0.0");
        HostNETMASKeth1->addSelection("/7     254.0.0.0");
        HostNETMASKeth1->addSelection("/8     255.0.0.0");
        HostNETMASKeth1->addSelection("/9     255.128.0.0");
        HostNETMASKeth1->addSelection("/10    255.192.0.0 ");
        HostNETMASKeth1->addSelection("/11    255.224.0.0");
        HostNETMASKeth1->addSelection("/12    255.240.0.0");
        HostNETMASKeth1->addSelection("/13    255.248.0.0");
        HostNETMASKeth1->addSelection("/14    255.252.0.0");
        HostNETMASKeth1->addSelection("/15    255.254.0.0");
        HostNETMASKeth1->addSelection("/16    255.255.0.0");
        HostNETMASKeth1->addSelection("/17    255.255.128.0");
        HostNETMASKeth1->addSelection("/18    255.255.192.0");
        HostNETMASKeth1->addSelection("/19    255.255.224.0");
        HostNETMASKeth1->addSelection("/20    255.255.240.0");
        HostNETMASKeth1->addSelection("/21    255.255.248.0");
        HostNETMASKeth1->addSelection("/22    255.255.252.0");
        HostNETMASKeth1->addSelection("/23    255.255.254.0");
        HostNETMASKeth1->addSelection("/24    255.255.255.0");
        HostNETMASKeth1->addSelection("/25    255.255.255.128");
        HostNETMASKeth1->addSelection("/26    255.255.255.192");
        HostNETMASKeth1->addSelection("/27    255.255.255.224");
        HostNETMASKeth1->addSelection("/28    255.255.255.240");
        HostNETMASKeth1->addSelection("/29    255.255.255.248");
        HostNETMASKeth1->addSelection("/30    255.255.255.252");
        HostNETMASKeth1->addSelection("/31    255.255.255.254");
        HostNETMASKeth1->addSelection("/32    255.255.255.255");
        HostNETMASKeth1->setHelpText(QObject::tr("Netmask"));
        HostNETMASKeth1->setValue(24);

        HostLineEdit *HostGWeth1 = new HostLineEdit("HostGWeth1");
        HostGWeth1->setLabel(QObject::tr("Gateway"));
        HostGWeth1->setValue("192.168.1.1");
        HostGWeth1->setHelpText(QObject::tr("This is the default route"));


        HostLineEdit *HostDNSeth1 = new HostLineEdit("HostDNSeth1");
        HostDNSeth1->setLabel(QObject::tr("Name server"));
        HostDNSeth1->setValue("192.168.1.1");
        HostDNSeth1->setHelpText(QObject::tr("Name server"));


        HostCheckBox *HostActiveonbooteth1 = new HostCheckBox("HostActiveonbooteth1");
        HostActiveonbooteth1->setLabel(QObject::tr("Active"));
        HostActiveonbooteth1->setValue(false);
        HostActiveonbooteth1->setHelpText(QObject::tr("Network is started on boot"));

        HostDefaulteth1 = new HostCheckBox("HostDefaulteth1");
        HostDefaulteth1->setLabel(QObject::tr("Default"));
        HostDefaulteth1->setValue(false);
        HostDefaulteth1->setHelpText(QObject::tr("Will be used as the primary interface"));
        connect(HostDefaulteth1, SIGNAL(valueChanged(bool)), this, SLOT(eth1_disable_others()));

        HostCheckBox *HostUseDHCPeth1 = new HostCheckBox("HostUseDHCPeth1");
        HostUseDHCPeth1 ->setLabel(QObject::tr("Static ip address"));
        HostUseDHCPeth1 ->setValue(false);
        HostUseDHCPeth1 ->setHelpText(QObject::tr("Enable to use a static ip address, otherwise dhcp will be used."));

        wirelessbuttoneth1 = new TransButtonSetting();
        wirelessbuttoneth1->setLabel(tr("Wireless Settings"));
        connect(wirelessbuttoneth1, SIGNAL(pressed()), this,   SLOT(eth1_wireless_settings()));

        ConfigurationGroup* settings1 = new GridConfigurationGroup(3,false, false, false,false);
            settings1->addChild(HostActiveonbooteth1);
            settings1->addChild(HostDefaulteth1);
            settings1-> addChild(wirelessbuttoneth1);

        addChild(settings1);

        Setting* dhcpEnabled = HostUseDHCPeth1;
        addChild(dhcpEnabled);
        setTrigger(dhcpEnabled);

        ConfigurationGroup* settings = new VerticalConfigurationGroup(false, false,false,false);
            settings->addChild(HostIPeth1);
            settings->addChild(HostNETMASKeth1);
            settings->addChild(HostGWeth1);
            settings->addChild(HostDNSeth1);

        addTarget("0", new VerticalConfigurationGroup(false,false,false,false));
        addTarget("1", settings);
};
eth1options::eth1options()
{

    VerticalConfigurationGroup* rec = new VerticalConfigurationGroup(false);
    rec->setLabel(QObject::tr("Wireless configuration for eth1"));
    //rec->setUseLabel(true);
    rec->addChild(new eth1_settings);
    addChild(rec);
}

void NetworkSettingseth1::eth1_disable_others()
{
        QString my_current_value;
        my_current_value = HostDefaulteth1->getValue();
        if ( my_current_value == "1" )
        {
            cout <<"ETH1: set other defaults buttons to off"<<endl;
            hostparm.ThisHostDefaultInterface="eth1";
            emit eth1_is_default();
        }
}
void NetworkSettingseth1::eth1_disabled()
{
    cout << "   eth1 is not default" << endl;
        HostDefaulteth1->setValue(0);
}

void NetworkSettingseth1::eth1_wireless_settings(void)
{
    //cout <<"button pressed for eth1"<<endl;
    eth1options eth1screen;
    eth1screen.exec();
}

void NetworkSettingseth1::eth1_wireless_disable()
{
    cout << "    eth1 disabling wireless button" << endl;
    wirelessbuttoneth1->setEnabled(false);
}


class wlan0_settings:          public TriggeredConfigurationGroup {
public:
    wlan0_settings():
    TriggeredConfigurationGroup(true,false,true,true,false,false,false,true) {

    HostComboBox *HOSTESSIDwlan0 = new HostComboBox("HOSTESSIDwlan0",true);
        HOSTESSIDwlan0->setLabel(QObject::tr("ESSID"));
        HOSTESSIDwlan0->addSelection("MythVantage");
        HOSTESSIDwlan0->addSelection("home_lan");
        HOSTESSIDwlan0->addSelection("type_it_here");
        HOSTESSIDwlan0->setHelpText(QObject::tr("ESSID"));
    addChild(HOSTESSIDwlan0);
    HostComboBox *HostUseEncryptionwlan0 = new HostComboBox("HostUseEncryptionwlan0");
        HostUseEncryptionwlan0->setLabel(QObject::tr("Encryption"));
        HostUseEncryptionwlan0->setHelpText(QObject::tr("WPA, WEP, none"));
        HostUseEncryptionwlan0->addSelection("none");
        HostUseEncryptionwlan0->addSelection("WPA");
        HostUseEncryptionwlan0->addSelection("WEP");

    Setting*  HostUseEncryption =  HostUseEncryptionwlan0;
        addChild(HostUseEncryption);
        setTrigger(HostUseEncryption);

    HostLineEdit *Hostkeywlan0 = new HostLineEdit("Hostkeywlan0");
        Hostkeywlan0->setLabel(QObject::tr("key"));
        Hostkeywlan0->setHelpText(QObject::tr("Key to use for encryption"));

    ConfigurationGroup* settings = new GridConfigurationGroup(1,false);
        settings->addChild(Hostkeywlan0);
    addTarget("none", new GridConfigurationGroup(1,false));
    addTarget("WPA", settings);
    addTarget("WEP", settings);
    //-
    };
};

NetworkSettingswlan0::NetworkSettingswlan0():
        TriggeredConfigurationGroup(false,false,false,false) {
        setLabel(QObject::tr("Network Settings"));

    HostIPwlan0 = new HostLineEdit("HostIPwlan0");
    HostIPwlan0->setLabel(QObject::tr("Ip address"));
    HostIPwlan0->setValue("192.168.1.12");
    HostIPwlan0->setHelpText(QObject::tr("IP address of the new installation"));

    HostNETMASKwlan0 = new HostComboBox("HostNETMASKwlan0");
        HostNETMASKwlan0->setLabel(QObject::tr("Netmask"));
        HostNETMASKwlan0->addSelection("/0     0.0.0.0");
        HostNETMASKwlan0->addSelection("/1     128.0.0.0");
        HostNETMASKwlan0->addSelection("/2     192.0.0.0");
        HostNETMASKwlan0->addSelection("/3     224.0.0.0");
        HostNETMASKwlan0->addSelection("/4     240.0.0.0");
        HostNETMASKwlan0->addSelection("/5     248.0.0.0");
        HostNETMASKwlan0->addSelection("/6     252.0.0.0");
        HostNETMASKwlan0->addSelection("/7     254.0.0.0");
        HostNETMASKwlan0->addSelection("/8     255.0.0.0");
        HostNETMASKwlan0->addSelection("/9     255.128.0.0");
        HostNETMASKwlan0->addSelection("/10    255.192.0.0 ");
        HostNETMASKwlan0->addSelection("/11    255.224.0.0");
        HostNETMASKwlan0->addSelection("/12    255.240.0.0");
        HostNETMASKwlan0->addSelection("/13    255.248.0.0");
        HostNETMASKwlan0->addSelection("/14    255.252.0.0");
        HostNETMASKwlan0->addSelection("/15    255.254.0.0");
        HostNETMASKwlan0->addSelection("/16    255.255.0.0");
        HostNETMASKwlan0->addSelection("/17    255.255.128.0");
        HostNETMASKwlan0->addSelection("/18    255.255.192.0");
        HostNETMASKwlan0->addSelection("/19    255.255.224.0");
        HostNETMASKwlan0->addSelection("/20    255.255.240.0");
        HostNETMASKwlan0->addSelection("/21    255.255.248.0");
        HostNETMASKwlan0->addSelection("/22    255.255.252.0");
        HostNETMASKwlan0->addSelection("/23    255.255.254.0");
        HostNETMASKwlan0->addSelection("/24    255.255.255.0");
        HostNETMASKwlan0->addSelection("/25    255.255.255.128");
        HostNETMASKwlan0->addSelection("/26    255.255.255.192");
        HostNETMASKwlan0->addSelection("/27    255.255.255.224");
        HostNETMASKwlan0->addSelection("/28    255.255.255.240");
        HostNETMASKwlan0->addSelection("/29    255.255.255.248");
        HostNETMASKwlan0->addSelection("/30    255.255.255.252");
        HostNETMASKwlan0->addSelection("/31    255.255.255.254");
        HostNETMASKwlan0->addSelection("/32    255.255.255.255");
        HostNETMASKwlan0->setHelpText(QObject::tr("Netmask"));
        HostNETMASKwlan0->setValue(24);

        HostGWwlan0 = new HostLineEdit("HostGWwlan0");
        HostGWwlan0->setLabel(QObject::tr("Gateway"));
        HostGWwlan0->setValue("192.168.1.1");
        HostGWwlan0->setHelpText(QObject::tr("This is the default route"));


        HostDNSwlan0 = new HostLineEdit("HostDNSwlan0");
        HostDNSwlan0->setLabel(QObject::tr("Name server"));
        HostDNSwlan0->setValue("192.168.1.1");
        HostDNSwlan0->setHelpText(QObject::tr("Name server"));


        HostActiveonbootwlan0 = new HostCheckBox("HostActiveonbootwlan0");
        HostActiveonbootwlan0->setLabel(QObject::tr("Active"));
        HostActiveonbootwlan0->setValue(false);
        HostActiveonbootwlan0->setHelpText(QObject::tr("Network is started on boot"));

        HostDefaultwlan0 = new HostCheckBox("HostDefaultwlan0");
        HostDefaultwlan0->setLabel(QObject::tr("Default"));
        HostDefaultwlan0->setValue(false);
        HostDefaultwlan0->setHelpText(QObject::tr("Will be used as the primary interface"));
        connect(HostDefaultwlan0, SIGNAL(valueChanged(bool)), this, SLOT(wlan0_disable_others()));



        HostUseDHCPwlan0 = new HostCheckBox("HostUseDHCPwlan0");
        HostUseDHCPwlan0 ->setLabel(QObject::tr("Static ip address"));
        HostUseDHCPwlan0 ->setValue(false);
        HostUseDHCPwlan0 ->setHelpText(QObject::tr("Enable to use a static ip address, otherwise dhcp will be used."));

        wirelessbuttonwlan0 = new TransButtonSetting();
        wirelessbuttonwlan0->setLabel(tr("Wireless Settings"));
        connect(wirelessbuttonwlan0, SIGNAL(pressed()), this,   SLOT(wlan0_wireless_settings()));


        ConfigurationGroup* settings1 = new GridConfigurationGroup(3,false, false, false,false);
            settings1->addChild(HostActiveonbootwlan0);
            settings1->addChild(HostDefaultwlan0);
            settings1-> addChild(wirelessbuttonwlan0);
        addChild(settings1);

        Setting* dhcpEnabled = HostUseDHCPwlan0;
        addChild(dhcpEnabled);
        setTrigger(dhcpEnabled);

        ConfigurationGroup* settings = new VerticalConfigurationGroup(false, false,false,false);
            settings->addChild(HostIPwlan0);
            settings->addChild(HostNETMASKwlan0);
            settings->addChild(HostGWwlan0);
            settings->addChild(HostDNSwlan0);

        addTarget("0", new VerticalConfigurationGroup(false,false,false,false));
        addTarget("1", settings);

};

Wlan0options::Wlan0options()
{

    VerticalConfigurationGroup* rec = new VerticalConfigurationGroup(false);
    rec->setLabel(QObject::tr("Wireless configuration for wlan0"));
    //rec->setUseLabel(true);
    rec->addChild(new wlan0_settings);
    addChild(rec);
}

void NetworkSettingswlan0::wlan0_disable_others()
{
        QString my_current_value;
        my_current_value = HostDefaultwlan0->getValue();
        if ( my_current_value == "1" )
        {
            cout <<"WLAN0: set other defaults buttons to off"<<endl;
        hostparm.ThisHostDefaultInterface="wlan0";
            emit wlan0_is_default();
        }



}
void NetworkSettingswlan0::wlan0_disabled()
{
    cout << "   wlan0 is not default" << endl;
    HostDefaultwlan0->setValue(0);
}


void NetworkSettingswlan0::wlan0_wireless_settings(void)
{
    //cout <<"button pressed for wlan0"<<endl;
    Wlan0options wlan0screen;
    wlan0screen.exec();
}
void NetworkSettingswlan0::wlan0_wireless_disable()
{
    cout << "    wlan0 disabling wireless button" << endl;
    wirelessbuttonwlan0->setEnabled(false);
}


class wlan1_settings:          public TriggeredConfigurationGroup {
public:
    wlan1_settings():
    TriggeredConfigurationGroup(true,false,true,true,false,false,false,true) {

    HostComboBox *HOSTESSIDwlan1 = new HostComboBox("HOSTESSIDwlan1",true);
        HOSTESSIDwlan1->setLabel(QObject::tr("ESSID"));
        HOSTESSIDwlan1->addSelection("MythVantage");
        HOSTESSIDwlan1->addSelection("home_lan");
        HOSTESSIDwlan1->addSelection("type_it_here");
        HOSTESSIDwlan1->setHelpText(QObject::tr("ESSID"));
    addChild(HOSTESSIDwlan1);


    HostComboBox *HostUseEncryptionwlan1 = new HostComboBox("HostUseEncryptionwlan1");
        HostUseEncryptionwlan1->setLabel(QObject::tr("Encryption"));
        HostUseEncryptionwlan1->setHelpText(QObject::tr("WPA, WEP, none"));
        HostUseEncryptionwlan1->addSelection("none");
        HostUseEncryptionwlan1->addSelection("WPA");
        HostUseEncryptionwlan1->addSelection("WEP");

    Setting*  HostUseEncryption =  HostUseEncryptionwlan1;
        addChild(HostUseEncryption);
        setTrigger(HostUseEncryption);

    HostLineEdit *Hostkeywlan1 = new HostLineEdit("Hostkeywlan1");
        Hostkeywlan1->setLabel(QObject::tr("key"));
        Hostkeywlan1->setHelpText(QObject::tr("Key to use for encryption"));

    ConfigurationGroup* settings = new GridConfigurationGroup(1,false);
        settings->addChild(Hostkeywlan1);
    addTarget("none", new GridConfigurationGroup(1,false));
    addTarget("WPA", settings);
    addTarget("WEP", settings);
    //-
    };
};

NetworkSettingswlan1::NetworkSettingswlan1():
        TriggeredConfigurationGroup(false,false,false,false) {
        setLabel(QObject::tr("Network Settings"));

    HostIPwlan1 = new HostLineEdit("HostIPwlan1");
    HostIPwlan1->setLabel(QObject::tr("Ip address"));
    HostIPwlan1->setValue("192.168.1.12");
    HostIPwlan1->setHelpText(QObject::tr("IP address of the new installation"));

    HostNETMASKwlan1 = new HostComboBox("HostNETMASKwlan1");
        HostNETMASKwlan1->setLabel(QObject::tr("Netmask"));
        HostNETMASKwlan1->addSelection("/0     0.0.0.0");
        HostNETMASKwlan1->addSelection("/1     128.0.0.0");
        HostNETMASKwlan1->addSelection("/2     192.0.0.0");
        HostNETMASKwlan1->addSelection("/3     224.0.0.0");
        HostNETMASKwlan1->addSelection("/4     240.0.0.0");
        HostNETMASKwlan1->addSelection("/5     248.0.0.0");
        HostNETMASKwlan1->addSelection("/6     252.0.0.0");
        HostNETMASKwlan1->addSelection("/7     254.0.0.0");
        HostNETMASKwlan1->addSelection("/8     255.0.0.0");
        HostNETMASKwlan1->addSelection("/9     255.128.0.0");
        HostNETMASKwlan1->addSelection("/10    255.192.0.0 ");
        HostNETMASKwlan1->addSelection("/11    255.224.0.0");
        HostNETMASKwlan1->addSelection("/12    255.240.0.0");
        HostNETMASKwlan1->addSelection("/13    255.248.0.0");
        HostNETMASKwlan1->addSelection("/14    255.252.0.0");
        HostNETMASKwlan1->addSelection("/15    255.254.0.0");
        HostNETMASKwlan1->addSelection("/16    255.255.0.0");
        HostNETMASKwlan1->addSelection("/17    255.255.128.0");
        HostNETMASKwlan1->addSelection("/18    255.255.192.0");
        HostNETMASKwlan1->addSelection("/19    255.255.224.0");
        HostNETMASKwlan1->addSelection("/20    255.255.240.0");
        HostNETMASKwlan1->addSelection("/21    255.255.248.0");
        HostNETMASKwlan1->addSelection("/22    255.255.252.0");
        HostNETMASKwlan1->addSelection("/23    255.255.254.0");
        HostNETMASKwlan1->addSelection("/24    255.255.255.0");
        HostNETMASKwlan1->addSelection("/25    255.255.255.128");
        HostNETMASKwlan1->addSelection("/26    255.255.255.192");
        HostNETMASKwlan1->addSelection("/27    255.255.255.224");
        HostNETMASKwlan1->addSelection("/28    255.255.255.240");
        HostNETMASKwlan1->addSelection("/29    255.255.255.248");
        HostNETMASKwlan1->addSelection("/30    255.255.255.252");
        HostNETMASKwlan1->addSelection("/31    255.255.255.254");
        HostNETMASKwlan1->addSelection("/32    255.255.255.255");
        HostNETMASKwlan1->setHelpText(QObject::tr("Netmask"));
        HostNETMASKwlan1->setValue(24);

        HostGWwlan1 = new HostLineEdit("HostGWwlan1");
        HostGWwlan1->setLabel(QObject::tr("Gateway"));
        HostGWwlan1->setValue("192.168.1.1");
        HostGWwlan1->setHelpText(QObject::tr("This is the default route"));


        HostDNSwlan1 = new HostLineEdit("HostDNSwlan1");
        HostDNSwlan1->setLabel(QObject::tr("Name server"));
        HostDNSwlan1->setValue("192.168.1.1");
        HostDNSwlan1->setHelpText(QObject::tr("Name server"));


        HostActiveonbootwlan1 = new HostCheckBox("HostActiveonbootwlan1");
        HostActiveonbootwlan1->setLabel(QObject::tr("Active"));
        HostActiveonbootwlan1->setValue(false);
        HostActiveonbootwlan1->setHelpText(QObject::tr("Network is started on boot"));

        HostUseDHCPwlan1 = new HostCheckBox("HostUseDHCPwlan1");
        HostUseDHCPwlan1 ->setLabel(QObject::tr("Static ip address"));
        HostUseDHCPwlan1 ->setValue(false);
        HostUseDHCPwlan1 ->setHelpText(QObject::tr("Enable to use a static ip address, otherwise dhcp will be used."));

        wirelessbuttonwlan1 = new TransButtonSetting();
        wirelessbuttonwlan1->setLabel(tr("Wireless Settings"));
        connect(wirelessbuttonwlan1, SIGNAL(pressed()), this,   SLOT(wlan1_wireless_settings()));

        HostDefaultwlan1 = new HostCheckBox("HostDefaultwlan1");
        HostDefaultwlan1->setLabel(QObject::tr("Default"));
        HostDefaultwlan1->setValue(false);
        HostDefaultwlan1->setHelpText(QObject::tr("Will be used as the primary interface"));
        connect(HostDefaultwlan1, SIGNAL(valueChanged(bool)), this, SLOT(wlan1_disable_others()));


        ConfigurationGroup* settings1 = new GridConfigurationGroup(3,false, false, false, false);
            settings1->addChild(HostActiveonbootwlan1);
            settings1->addChild(HostDefaultwlan1);
            settings1-> addChild(wirelessbuttonwlan1);

        addChild(settings1);

        Setting* dhcpEnabled = HostUseDHCPwlan1;
        addChild(dhcpEnabled);
        setTrigger(dhcpEnabled);

        ConfigurationGroup* settings = new VerticalConfigurationGroup(false, false,false,false);
            settings->addChild(HostIPwlan1);
            settings->addChild(HostNETMASKwlan1);
            settings->addChild(HostGWwlan1);
            settings->addChild(HostDNSwlan1);

        addTarget("0", new VerticalConfigurationGroup(true));
        addTarget("1", settings);

};

wlan1options::wlan1options()
{
    VerticalConfigurationGroup* rec = new VerticalConfigurationGroup(false);
    rec->setLabel(QObject::tr("Wireless configuration for wlan1"));
    //rec->setUseLabel(true);
    rec->addChild(new wlan1_settings);
    addChild(rec);
}
void NetworkSettingswlan1::wlan1_disable_others()
{
        QString my_current_value;
        my_current_value = HostDefaultwlan1->getValue();
        if ( my_current_value == "1" )
        {
            cout <<"WLAN1:  set other defaults buttons to off"<<endl;
        hostparm.ThisHostDefaultInterface="wlan1";
            emit wlan1_is_default();
        }
}

void NetworkSettingswlan1::wlan1_disabled()
{
    cout << "   wlan1 is not default" << endl;
    HostDefaultwlan1->setValue(0);


}
void NetworkSettingswlan1::wlan1_wireless_disable()
{
    cout << "    wlan1 disabling wireless button" << endl;
    wirelessbuttonwlan1->setEnabled(false);
}

void NetworkSettingswlan1::wlan1_wireless_settings(void)
{
//  cout <<"button pressed for wlan1"<<endl;
    wlan1options wlan1screen;
    wlan1screen.exec();
}

//---

class ath0_settings:          public TriggeredConfigurationGroup {
public:
    ath0_settings():
    TriggeredConfigurationGroup(true,false,true,true,false,false,false,true) {

    HostComboBox *HOSTESSIDath0 = new HostComboBox("HOSTESSIDath0",true);
        HOSTESSIDath0->setLabel(QObject::tr("ESSID"));
        HOSTESSIDath0->addSelection("MythVantage");
        HOSTESSIDath0->addSelection("home_lan");
        HOSTESSIDath0->addSelection("type_it_here");
        HOSTESSIDath0->setHelpText(QObject::tr("ESSID"));
    addChild(HOSTESSIDath0);

        HostComboBox *HostUseEncryptionath0 = new HostComboBox("HostUseEncryptionath0");
        HostUseEncryptionath0->setLabel(QObject::tr("Encryption"));
        HostUseEncryptionath0->setHelpText(QObject::tr("WPA, WEP, none"));
        HostUseEncryptionath0->addSelection("none");
        HostUseEncryptionath0->addSelection("WPA");
        HostUseEncryptionath0->addSelection("WEP");

    Setting*  HostUseEncryption =  HostUseEncryptionath0;
        addChild(HostUseEncryption);
        setTrigger(HostUseEncryption);

    HostLineEdit *Hostkeyath0 = new HostLineEdit("Hostkeyath0");
        Hostkeyath0->setLabel(QObject::tr("key"));
        Hostkeyath0->setHelpText(QObject::tr("Key to use for encryption"));

    ConfigurationGroup* settings = new GridConfigurationGroup(1,false);
        settings->addChild(Hostkeyath0);
    addTarget("none", new GridConfigurationGroup(1,false));
    addTarget("WPA", settings);
    addTarget("WEP", settings);
    //-

    };
};


NetworkSettingsath0::NetworkSettingsath0():
        TriggeredConfigurationGroup(false,false,false,false) {
    setLabel(QObject::tr("Network Settings"));
    HostLineEdit  *HostIPath0 = new HostLineEdit("HostIPath0");
    HostIPath0->setLabel(QObject::tr("Ip address"));
    HostIPath0->setValue("192.168.1.12");
    HostIPath0->setHelpText(QObject::tr("IP address of the new installation"));

    HostComboBox *HostNETMASKath0 = new HostComboBox("HostNETMASKath0");
        HostNETMASKath0->setLabel(QObject::tr("Netmask"));
        HostNETMASKath0->addSelection("/0     0.0.0.0");
        HostNETMASKath0->addSelection("/1     128.0.0.0");
        HostNETMASKath0->addSelection("/2     192.0.0.0");
        HostNETMASKath0->addSelection("/3     224.0.0.0");
        HostNETMASKath0->addSelection("/4     240.0.0.0");
        HostNETMASKath0->addSelection("/5     248.0.0.0");
        HostNETMASKath0->addSelection("/6     252.0.0.0");
        HostNETMASKath0->addSelection("/7     254.0.0.0");
        HostNETMASKath0->addSelection("/8     255.0.0.0");
        HostNETMASKath0->addSelection("/9     255.128.0.0");
        HostNETMASKath0->addSelection("/10    255.192.0.0 ");
        HostNETMASKath0->addSelection("/11    255.224.0.0");
        HostNETMASKath0->addSelection("/12    255.240.0.0");
        HostNETMASKath0->addSelection("/13    255.248.0.0");
        HostNETMASKath0->addSelection("/14    255.252.0.0");
        HostNETMASKath0->addSelection("/15    255.254.0.0");
        HostNETMASKath0->addSelection("/16    255.255.0.0");
        HostNETMASKath0->addSelection("/17    255.255.128.0");
        HostNETMASKath0->addSelection("/18    255.255.192.0");
        HostNETMASKath0->addSelection("/19    255.255.224.0");
        HostNETMASKath0->addSelection("/20    255.255.240.0");
        HostNETMASKath0->addSelection("/21    255.255.248.0");
        HostNETMASKath0->addSelection("/22    255.255.252.0");
        HostNETMASKath0->addSelection("/23    255.255.254.0");
        HostNETMASKath0->addSelection("/24    255.255.255.0");
        HostNETMASKath0->addSelection("/25    255.255.255.128");
        HostNETMASKath0->addSelection("/26    255.255.255.192");
        HostNETMASKath0->addSelection("/27    255.255.255.224");
        HostNETMASKath0->addSelection("/28    255.255.255.240");
        HostNETMASKath0->addSelection("/29    255.255.255.248");
        HostNETMASKath0->addSelection("/30    255.255.255.252");
        HostNETMASKath0->addSelection("/31    255.255.255.254");
        HostNETMASKath0->addSelection("/32    255.255.255.255");
        HostNETMASKath0->setHelpText(QObject::tr("Netmask"));
        HostNETMASKath0->setValue(24);

        HostLineEdit *HostGWath0 = new HostLineEdit("HostGWath0");
        HostGWath0->setLabel(QObject::tr("Gateway"));
        HostGWath0->setValue("192.168.1.1");
        HostGWath0->setHelpText(QObject::tr("This is the default route"));


        HostLineEdit *HostDNSath0 = new HostLineEdit("HostDNSath0");
        HostDNSath0->setLabel(QObject::tr("Name server"));
        HostDNSath0->setValue("192.168.1.1");
        HostDNSath0->setHelpText(QObject::tr("Name server"));


        HostCheckBox *HostActiveonbootath0 = new HostCheckBox("HostActiveonbootath0");
        HostActiveonbootath0->setLabel(QObject::tr("Active"));
        HostActiveonbootath0->setValue(false);
        HostActiveonbootath0->setHelpText(QObject::tr("Network is started on boot"));

        HostDefaultath0 = new HostCheckBox("HostDefaultath0");
        HostDefaultath0->setLabel(QObject::tr("Default"));
        HostDefaultath0->setValue(false);
        HostDefaultath0->setHelpText(QObject::tr("Will be used as the primary interface"));
        connect(HostDefaultath0, SIGNAL(valueChanged(bool)), this, SLOT(ath0_disable_others()));

        HostCheckBox *HostUseDHCPath0 = new HostCheckBox("HostUseDHCPath0");
        HostUseDHCPath0 ->setLabel(QObject::tr("Static ip address"));
        HostUseDHCPath0 ->setValue(false);
        HostUseDHCPath0 ->setHelpText(QObject::tr("Enable to use a static ip address, otherwise dhcp will be used."));

        wirelessbuttonath0 = new TransButtonSetting();
        wirelessbuttonath0->setLabel(tr("Wireless Settings"));
        connect(wirelessbuttonath0, SIGNAL(pressed()), this,   SLOT(ath0_wireless_settings()));

        ConfigurationGroup* settings1 = new GridConfigurationGroup(3,false, false, false,false);
            settings1->addChild(HostActiveonbootath0);
            settings1->addChild(HostDefaultath0);
            settings1-> addChild(wirelessbuttonath0);

        addChild(settings1);

        Setting* dhcpEnabled = HostUseDHCPath0;
        addChild(dhcpEnabled);
        setTrigger(dhcpEnabled);

        ConfigurationGroup* settings = new VerticalConfigurationGroup(false, false,false,false);
            settings->addChild(HostIPath0);
            settings->addChild(HostNETMASKath0);
            settings->addChild(HostGWath0);
            settings->addChild(HostDNSath0);

        addTarget("0", new VerticalConfigurationGroup(false,false,false,false));
        addTarget("1", settings);
};
ath0options::ath0options()
{

    VerticalConfigurationGroup* rec = new VerticalConfigurationGroup(false);
    rec->setLabel(QObject::tr("Wireless configuration for ath0"));
    //rec->setUseLabel(true);
    rec->addChild(new ath0_settings);
    addChild(rec);
}

void NetworkSettingsath0::ath0_disable_others()
{
        QString my_current_value;
        my_current_value = HostDefaultath0->getValue();
        if ( my_current_value == "1" )
        {
            cout <<"ATH0: set other defaults buttons to off"<<endl;
            hostparm.ThisHostDefaultInterface="ath0";
            emit ath0_is_default();
        }
}
void NetworkSettingsath0::ath0_disabled()
{
    cout << "   ath0 is not default" << endl;
        HostDefaultath0->setValue(0);
}

void NetworkSettingsath0::ath0_wireless_settings(void)
{
    //cout <<"button pressed for ath0"<<endl;
    ath0options ath0screen;
    ath0screen.exec();
}

void NetworkSettingsath0::ath0_wireless_disable()
{
    cout << "    ath0 disabling wireless button" << endl;
    wirelessbuttonath0->setEnabled(false);
}


//--

class NetworkSettingsFrame:
                    public TriggeredConfigurationGroup {
public:
    NetworkSettingsFrame():
    TriggeredConfigurationGroup(false, false, true, true,false, false, true, true) {
        setLabel(QObject::tr("Network Settings Page (2/2)"));
        Setting* netdevice = HostNetDevice();
        addChild(netdevice);
        setTrigger(netdevice);

        NetworkSettingswlan0 *Nwlan0 = new NetworkSettingswlan0 ;
        NetworkSettingswlan1 *Nwlan1 = new NetworkSettingswlan1 ;
        NetworkSettingseth0 *Neth0 = new NetworkSettingseth0 ;
        NetworkSettingseth1 *Neth1 = new NetworkSettingseth1 ;
        NetworkSettingsath0 *Nath0 = new NetworkSettingsath0 ;

        QString found_wireless=findnet_wireless();

        if ( not found_wireless.contains("eth0"))
        {
            Neth0->eth0_wireless_disable();
            hostparm.ThisHOST_iswirelesseth0="0";
        }
        else
        {
            hostparm.ThisHOST_iswirelesseth0="1";
        }

        if ( not found_wireless.contains("eth1"))
        {
            Neth1->eth1_wireless_disable();
            hostparm.ThisHOST_iswirelesseth1="0";
        }
        else
        {
            hostparm.ThisHOST_iswirelesseth1="1";
        }

        if ( not found_wireless.contains("wlan0"))
        {
            Nwlan0->wlan0_wireless_disable();
            hostparm.ThisHOST_iswirelesswlan0="0";
        }
        else
        {
            hostparm.ThisHOST_iswirelesswlan0="1";
        }

        if ( not found_wireless.contains("wlan1"))
        {
            Nwlan1->wlan1_wireless_disable();
            hostparm.ThisHOST_iswirelesswlan1="0";
        }
        else
        {
            hostparm.ThisHOST_iswirelesswlan0="1";
        }

        if ( not found_wireless.contains("ath0"))
        {
            Nath0->ath0_wireless_disable();
            hostparm.ThisHOST_iswirelessath0="0";
        }
        else
        {
            hostparm.ThisHOST_iswirelessath0="1";
        }
        connect(Nwlan1, SIGNAL(wlan1_is_default(void)), Nwlan0,  SLOT(wlan0_disabled()));
        connect(Nwlan1, SIGNAL(wlan1_is_default(void)), Neth0,   SLOT(eth0_disabled()));
        connect(Nwlan1, SIGNAL(wlan1_is_default(void)), Neth1,   SLOT(eth1_disabled()));
        connect(Nwlan1, SIGNAL(wlan1_is_default(void)), Nath0,   SLOT(ath0_disabled()));

        connect(Nwlan0, SIGNAL(wlan0_is_default(void)), Nwlan1,  SLOT(wlan1_disabled()));
        connect(Nwlan0, SIGNAL(wlan0_is_default(void)), Neth0,   SLOT(eth0_disabled()));
        connect(Nwlan0, SIGNAL(wlan0_is_default(void)), Neth1,   SLOT(eth1_disabled()));
        connect(Nwlan0, SIGNAL(wlan0_is_default(void)), Nath0,   SLOT(ath0_disabled()));

        connect(Neth1, SIGNAL(eth1_is_default(void)), Nwlan1,   SLOT(wlan1_disabled()));
        connect(Neth1, SIGNAL(eth1_is_default(void)), Nwlan0,   SLOT(wlan0_disabled()));
        connect(Neth1, SIGNAL(eth1_is_default(void)), Neth0,    SLOT(eth0_disabled()));
        connect(Neth1, SIGNAL(eth1_is_default(void)), Nath0,    SLOT(ath0_disabled()));

        connect(Neth0, SIGNAL(eth0_is_default(void)), Nwlan0,   SLOT(wlan0_disabled()));
        connect(Neth0, SIGNAL(eth0_is_default(void)), Nwlan1,   SLOT(wlan1_disabled()));
        connect(Neth0, SIGNAL(eth0_is_default(void)), Neth1,    SLOT(eth1_disabled()));
        connect(Neth0, SIGNAL(eth0_is_default(void)), Nath0,    SLOT(ath0_disabled()));

        connect(Nath0, SIGNAL(ath0_is_default(void)), Nwlan0,   SLOT(wlan0_disabled()));
        connect(Nath0, SIGNAL(ath0_is_default(void)), Nwlan1,   SLOT(wlan1_disabled()));
        connect(Nath0, SIGNAL(ath0_is_default(void)), Neth1,    SLOT(eth1_disabled()));
        connect(Nath0, SIGNAL(ath0_is_default(void)), Neth0,    SLOT(eth0_disabled()));


        HostLineEdit *HostMTUeth0 = new HostLineEdit("HostMTUeth0");
        HostMTUeth0->setLabel(QObject::tr("MTU"));
        HostMTUeth0->setValue("");
        HostMTUeth0->setHelpText(QObject::tr("Leave this blank for default values.  Changing this setting can have adverse affects, use with caution. Not all values will be supported by the device."));

        ConfigurationGroup* settingseth0 = new GridConfigurationGroup(1,false, false, false, false);
            settingseth0->addChild(Neth0);
            settingseth0->addChild(HostMTUeth0);


        HostLineEdit *HostMTUeth1 = new HostLineEdit("HostMTUeth1");
        HostMTUeth1->setLabel(QObject::tr("MTU"));
        HostMTUeth1->setValue("");
        HostMTUeth1->setHelpText(QObject::tr("Leave this blank for default values.  Changing this setting can have adverse affects, use with caution.  Not all values will be supported by the device."));

        ConfigurationGroup* settingseth1 = new GridConfigurationGroup(1,false, false, true, true);
            settingseth1->addChild(Neth1);
            settingseth1->addChild(HostMTUeth1);

        HostLineEdit *HostMTUwlan0 = new HostLineEdit("HostMTUwlan0");
        HostMTUwlan0->setLabel(QObject::tr("MTU"));
        HostMTUwlan0->setValue("");
        HostMTUwlan0->setHelpText(QObject::tr("Leave this blank for default values.  Changing this setting can have adverse affects, use with caution. Not all values will be supported by the device."));

        ConfigurationGroup* settingswlan0 = new GridConfigurationGroup(1,false, false, false, false);
            settingswlan0->addChild(Nwlan0);
            settingswlan0->addChild(HostMTUwlan0);

        HostLineEdit *HostMTUwlan1 = new HostLineEdit("HostMTUwlan1");
        HostMTUwlan1->setLabel(QObject::tr("MTU"));
        HostMTUwlan1->setValue("");
        HostMTUwlan1->setHelpText(QObject::tr("Leave this blank for default values.  Changing this setting can have adverse affects, use with caution.  Not all values will be supported by the device."));

        ConfigurationGroup* settingswlan1 = new GridConfigurationGroup(1,false, false, false, false);
            settingswlan1->addChild(Nwlan1);
            settingswlan1->addChild(HostMTUwlan1);

        HostLineEdit *HostMTUath0 = new HostLineEdit("HostMTUath0");
        HostMTUath0->setLabel(QObject::tr("MTU"));
        HostMTUath0->setValue("");
        HostMTUath0->setHelpText(QObject::tr("Leave this blank for default values.  Changing this setting can have adverse affects, use with caution.  Not all values will be supported by the device."));

        ConfigurationGroup* settingsath0 = new GridConfigurationGroup(1,false, false, false, false);
            settingsath0->addChild(Nath0);
            settingsath0->addChild(HostMTUath0);



        addTarget("wlan0", settingswlan0);
        addTarget("wlan1", settingswlan1);
        addTarget("eth0",  settingseth0);
        addTarget("eth1",  settingseth1);
        addTarget("ath0",  settingsath0);
    };
};


static HostCheckBox *HostAutodown()
{
    HostCheckBox *gc = new HostCheckBox("HostAutodown");
    gc->setLabel(QObject::tr("Turn off machine at a specified time"));
    gc->setValue(false);
    gc->setHelpText(QObject::tr("Will turn off this system."));
    return gc;
};


static HostSpinBox *HostWakeupTime()
{
    HostSpinBox *gc = new HostSpinBox("HostWakeupTime", -1, 23, 1, true);
    gc->setLabel(QObject::tr("Power on  time"));
    gc->setValue(6);
    gc->setHelpText(QObject::tr("Select the hour to auto poweron this system. Use -1 to disable"  ));
    return gc;
}



static HostSpinBox *HostShutdownTime()
{
    HostSpinBox *gc = new HostSpinBox("HostShutdownTime", -1, 23, 1, true);
    gc->setLabel(QObject::tr("Auto Shutdown time"));
    gc->setValue(2);
    gc->setHelpText(QObject::tr("Select the hour to  poweroff this syste.  Times are in 24hour format.  Use -1 to disable"  ));
    return gc;
}
static HostSpinBox *HostShutdownTime2()
{
    HostSpinBox *gc = new HostSpinBox("HostShutdownTime2", -1, 23, 1, true);
    gc->setLabel(QObject::tr("2nd auto Shutdown time"));
    gc->setValue(2);
    gc->setHelpText(QObject::tr("Select the hour to  poweroff this syste.  Times are in 24hour format.  Use -1 to disable"  ));
    return gc;
}



static HostCheckBox *HostUseWOL()
{
    HostCheckBox *gc = new HostCheckBox("HostUseWOL");
    gc->setLabel(QObject::tr("Use Wake on Lan to turn on system"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Unless you know what your doing leave it checked"));
    return gc;
};

static HostCheckBox *HostUseNVRAM()
{
    HostCheckBox *gc = new HostCheckBox("HostUseNVRAM");
    gc->setLabel(QObject::tr("Use nvram to turn on system"));
    gc->setValue(true);
    gc->setHelpText(QObject::tr("Leaved checked unless nvram causes problems."));
    return gc;
};





class WakeSettings:                     public TriggeredConfigurationGroup {
public:
    WakeSettings():

        TriggeredConfigurationGroup(true) {
        setLabel(QObject::tr("Shutdown Settings"));
        Setting* Autodown = HostAutodown();
        addChild(Autodown);
        setTrigger(Autodown);
        ConfigurationGroup* settings = new VerticalConfigurationGroup(false);
            settings->addChild(HostShutdownTime());
            settings->addChild(HostShutdownTime2());
            settings->addChild(HostWakeupTime());
            settings->addChild(HostUseNVRAM());
            settings->addChild(HostUseWOL());
        addTarget("0", new VerticalConfigurationGroup(true));
        addTarget("1", settings);

    };
};

class Frontend_settings_group:          public TriggeredConfigurationGroup {
public:
    Frontend_settings_group():
        TriggeredConfigurationGroup(true,false,true,true,false,false,false,true) {
        Setting* fe = HostRunFrontend();
        addChild(fe);
        setTrigger(fe);
    //HostXres = new HostComboBox("HostXres");
    ConfigurationGroup* setting1 = new GridConfigurationGroup(2,false);
            setting1->addChild(HostXres());
            setting1->addChild(HostUsemythfrontend());

    ConfigurationGroup* settings = new VerticalConfigurationGroup(false);
            settings->addChild(setting1);
            settings->addChild(new HostRemoteType);

    addTarget("0", new VerticalConfigurationGroup(false));
    addTarget("1", settings);

    };
};

SystemtypeGroup::SystemtypeGroup():        TriggeredConfigurationGroup(true,true,true,true,true,true,true,true) {
        setLabel(QObject::tr("System Type"));
        HostSystemType = new HostComboBox("HostSystemType");
        HostSystemType->setLabel(QObject::tr("Type of system setup"));
        HostSystemType->addSelection("Standalone");
        HostSystemType->addSelection("Frontend_only");
        HostSystemType->addSelection("Master_backend");
        HostSystemType->addSelection("Slave_backend");

// HostXres = new HostComboBox("HostXres");
        if ( ((gContext->GetSetting("HostaccesshostypeSystemtype")) == "0" ))
            HostSystemType->setEnabled(false);

        addChild(HostSystemType);
        setTrigger(HostSystemType);

        ConfigurationGroup* standalone = new VerticalConfigurationGroup(false,false,true,true);
            standalone->addChild(HostXres());
            standalone->addChild(new HostRemoteType);
            standalone->addChild(HostUsemythfrontend());

        ConfigurationGroup* frontend = new VerticalConfigurationGroup(false,false,true,true);
            frontend->addChild(HostMysqlserverip_listbox());
            frontend->addChild(HostXres());
            frontend->addChild(new HostRemoteType);
            frontend->addChild(HostUsemythfrontend());

        ConfigurationGroup* backend = new VerticalConfigurationGroup(false,false,false,false);
            backend->addChild( new Frontend_settings_group);

        ConfigurationGroup* slave = new VerticalConfigurationGroup(false,false,true,true);
            slave->addChild(HostMysqlserverip_listbox());
            slave->addChild( new Frontend_settings_group);


        addTarget("Standalone", standalone);
        addTarget("Frontend_only", frontend);
        addTarget("Master_backend", backend);
        addTarget("Slave_backend", slave);
        connect(HostSystemType, SIGNAL(valueChanged(const QString&)),
                this,    SLOT(SystemtypeHelp()));

    };

void SystemtypeGroup::SystemtypeHelp(void)
    {
        QString msg = (QObject::tr("Configuration for this system.  Most people will use standalone"));
        QString selectedhostype;
        selectedhostype = HostSystemType->getValue();
        if  ( selectedhostype.isEmpty())
        {
            HostSystemType->setHelpText(msg) ;
            return;
        }

        if (selectedhostype == "Standalone")
            msg="Complete System, that doesn't allow outside connections";
        if (selectedhostype == "Frontend_only")
            msg="Frontend only, needs a  master backend already on the network";
        if (selectedhostype ==  "Master_backend")
            msg="Tuners, scheduling and database.  This allows for remote frontend and slave backends";
        if (selectedhostype == "Slave_backend")
            msg="Extra tuners";

        HostSystemType->setHelpText(msg) ;
}



HostRemoteType::HostRemoteType():
    HostImageSelect("HostRemoteType") {
    setLabel(QObject::tr("Remote"));
    QString dirtxt;
    dirtxt=MV_ROOT;
    dirtxt.append("templates/remotes");
    QDir remotes(dirtxt);
    remotes.setFilter(QDir::Dirs);
    remotes.setSorting(QDir::Name | QDir::IgnoreCase);
    const QFileInfoList *fil = remotes.entryInfoList(QDir::Dirs);
    if (!fil)
        return;

    QFileInfoListIterator it( *fil );
    QFileInfo *remote;
    for( ; it.current() != 0 ; ++it )
    {
        remote = it.current();
        QFileInfo preview(remote->absFilePath() + "/preview.jpg");
            if (remote->fileName()[0] == '.' || !preview.exists() )
            {
            //cout << remote->absFilePath() << " Can't find preivew image, doesn't look like a remote\n";
            continue;
            }
        QImage* previewImage = new QImage(preview.absFilePath());
        addImageSelection(remote->fileName(), previewImage);

    }

}
/*
static HostComboBox *HostLCDType()
{
    HostComboBox *gc = new HostComboBox("HostLCDType",false);
    gc->setLabel(QObject::tr("LCD/VFD model"));
    gc->addSelection("no_lcd");
    gc->addSelection("tinker");
    gc->setValue(0);
    gc->setHelpText(QObject::tr("VFD or LCD"));
    QString dirtxt;
    dirtxt=MV_ROOT;
    dirtxt.append("templates/LCD");
    QDir transmit(dirtxt);

    //QDir transmit("/usr/share/templates/LCD");
    transmit.setFilter(QDir::Dirs);
    transmit.setSorting(QDir::Name | QDir::IgnoreCase);
    const QFileInfoList *infos = transmit.entryInfoList();
    const QFileInfo *info;
    if (!infos)
        return gc;
    QFileInfoListIterator infoIt( *infos );
    QString currentitem = ".";
    while( (info=infoIt.current()) != 0 )
        {
            currentitem = info->baseName( TRUE );
            if ( currentitem != ".." && currentitem != "." && currentitem != "")
            {
            gc->addSelection(currentitem);
            }
        ++infoIt;
        }
    return gc;
};
*/

class AdvancedSettings:    public TriggeredConfigurationGroup {
public:
   void smb_busy_box() {
        system ("nmbscan -d  > /tmp/smbdomainlist & ");
        QString msgtext="Searching for windows workgroups";
        int return_code;
        MythBusyDialog *busy = new MythBusyDialog(msgtext);
        // yet another incorrect way todo things, but I don't know anybetter
        // as long as ps can find systemconfig in the list  the busy box will appear and update
        busy->start();
        while (  return_code == 0 )
        {
            return_code = myth_system("ps -ef|grep nmbscan|grep -v grep > /dev/null");
            qApp->processEvents ();
            usleep(900);
        }
        busy->Close();
        busy->deleteLater();
    }

    AdvancedSettings():
    TriggeredConfigurationGroup(true,true,true,true,true,true,true,true)
    {

        setLabel(QObject::tr("Advanced settings (1/3)"));
        Setting* Autodown = HostAutodown();
        setTrigger(Autodown);
        hostparm.ThisSystemType 	= gContext->GetSetting("HostSystemType");
        ConfigurationGroup *checkbox = new GridConfigurationGroup(2,false);
                checkbox->addChild(HostServiceMythWEB());
                checkbox->addChild(HostServiceNFS());
                checkbox->addChild(Hostbootsplash());
                checkbox->addChild(HostncidClient());

        ConfigurationGroup* settings = new VerticalConfigurationGroup(false);
        if  ( hostparm.ThisSystemType == "Standalone" )
        {
            smb_busy_box();
            settings->addChild(new NCIDsettings);
            settings->addChild(new SAMBAsettings);
            #ifdef __MVAPP__
                checkbox->addChild(GlobalServiceHobbitserver() );
            #else
                checkbox->addChild(HostServiceRRD() );
            #endif
            settings->addChild(checkbox)                ;
        }
        else if  (hostparm.ThisSystemType == "Master_backend" )
        {
            smb_busy_box();
                checkbox->addChild(GlobalPKG_MIRROR());
                settings->addChild(new NCIDsettings);
                settings->addChild(new SAMBAsettings);
            #ifdef __MVAPP__
                checkbox->addChild(GlobalServiceHobbitserver() );
            #else
                checkbox->addChild(HostServiceRRD() );
            #endif
                settings->addChild(checkbox)                ;
        }
        else if  (hostparm.ThisSystemType == "Frontend_only" )
        {
            settings->addChild(Hostbootsplash());
            settings->addChild(HostncidClient());
            #ifdef __MVAPP__
                cout << gContext->GetSetting("GlobalServiceHobbitserver") << endl;
                cout << "above"<<endl;
                if  ( gContext->GetSetting("GlobalServiceHobbitserver") != "0" )
                    settings->addChild(HostServiceHobbitclient() );
            #else
                    settings->addChild(HostServiceRRD() );
            #endif


            if ( (gContext->GetSetting("GlobalPKG_MIRROR") ) == "1"  )
                    settings->addChild(HostPKG_MIRROR());
        }
    else if  (hostparm.ThisSystemType == "Slave_backend" )
        {
            settings->addChild(Hostbootsplash());
            settings->addChild(HostncidClient());
            #ifdef __MVAPP__
                if  ( gContext->GetSetting("GlobalServiceHobbitserver") != "0" )
                    settings->addChild(HostServiceHobbitclient() );
            #else
                    settings->addChild(HostServiceRRD() );
            #endif

            if (  (gContext->GetSetting("GlobalPKG_MIRROR")) == "1")
                    settings->addChild(HostPKG_MIRROR());
        };
        addTarget("", settings);
    };
};


class AdvancedSettings_2:    public TriggeredConfigurationGroup {
public:
    AdvancedSettings_2():
    TriggeredConfigurationGroup(true,true,true,true,true,true,true,true) {
        setLabel(QObject::tr("Advanced settings (2/3)"));
        Setting* Autodown = HostAutodown();
        setTrigger(Autodown);
        hostparm.ThisSystemType     = gContext->GetSetting("HostSystemType");

        ConfigurationGroup *checkbox = new GridConfigurationGroup(2,false);
                checkbox->addChild(HostServiceMythWEB());
                checkbox->addChild(HostServiceNFS());
                checkbox->addChild(Hostbootsplash());
                checkbox->addChild(HostncidClient());

        ConfigurationGroup* settings = new VerticalConfigurationGroup(false);
            if  ( hostparm.ThisSystemType == "Standalone" )
            {
//                     settings->addChild(HostLCDType());
//                     settings->addChild(HostTransmitproto());
//                     settings->addChild(new LIRCsettings);
                    settings->addChild(HostRunDHCP());

                    settings->addChild(new Evroutersettings);
            }
            else if  (hostparm.ThisSystemType == "Master_backend" )
            {
//                     settings->addChild(HostLCDType());
//                     settings->addChild(HostTransmitproto());
//                     settings->addChild(new LIRCsettings);
                    settings->addChild(new Backupsettings);
                    settings->addChild(HostRunDHCP());
                     settings->addChild(new Evroutersettings);
            }
            else if  (hostparm.ThisSystemType == "Frontend_only" )
            {
//                     settings->addChild(HostLCDType());
//                     settings->addChild(new LIRCsettings);
                        settings->addChild(new Evroutersettings);
            }
            else if  (hostparm.ThisSystemType == "Slave_backend" )
            {
//                     settings->addChild(HostLCDType());
//                     settings->addChild(HostTransmitproto());
//                     settings->addChild(new LIRCsettings);
                       settings->addChild(new Evroutersettings);
            };

        addTarget("", settings);

};
};



/*_______________________________Sound settings ____________________*/
SoundSettings::SoundSettings():
    TriggeredConfigurationGroup(true,true,true,true,true,true,true,true) {
        setLabel(QObject::tr("Audio out settings"));

    HostAudiotype = new HostComboBox("HostAudiotype",false);
    HostAudiotype->setLabel(QObject::tr("Sound card driver"));
    HostAudiotype->addSelection("OSS");
    HostAudiotype->addSelection("ALSA");
    HostAudiotype->addSelection("tinker");

    HostAudiotype->setHelpText(QObject::tr("OSS or ALSA, your choice"));
        addChild(HostAudiotype);
        setTrigger(HostAudiotype);

    HostsyncXine = new HostCheckBox("HostsyncXine");
    HostsyncXine->setLabel(QObject::tr("Xine"));
    HostsyncXine->setValue(true);

    HostsyncMplayer = new HostCheckBox("HostsyncMplayer");
    HostsyncMplayer->setLabel(QObject::tr("mplayer"));
    HostsyncMplayer->setValue(true);

    HostsyncMythMusic = new HostCheckBox("HostsyncMythMusic");
    HostsyncMythMusic->setLabel(QObject::tr("mythmusic"));
    HostsyncMythMusic->setValue(true);

    HostsyncMythFrontend = new HostCheckBox("HostsyncMythFrontend");
    HostsyncMythFrontend->setLabel(QObject::tr("mythfrontend"));
    HostsyncMythFrontend->setValue(true);

    HorizontalConfigurationGroup *syncboxes =   new HorizontalConfigurationGroup(false, false, true, true);
        syncboxes->addChild(HostsyncXine);
        syncboxes->addChild(HostsyncMplayer);
        syncboxes->addChild(HostsyncMythMusic);
        syncboxes->addChild(HostsyncMythFrontend);

    HorizontalConfigurationGroup *lp = new HorizontalConfigurationGroup(false, false, true, true);
    HorizontalConfigurationGroup *lpalsa = new HorizontalConfigurationGroup(false, false, true, true);

    TransButtonSetting *LoadOSSbutton = new TransButtonSetting();
    LoadOSSbutton->setLabel(tr("Load OSS driver"));
    TransButtonSetting *LoadALSAbutton = new TransButtonSetting();
    LoadALSAbutton->setLabel(tr("Load ALSA driver"));

    TransButtonSetting *TestAudiobutton = new TransButtonSetting();
    TestAudiobutton->setLabel(tr("Test Audio Settings"));
        lp->addChild(TestAudiobutton);
        lp->addChild(LoadOSSbutton);

    TransButtonSetting *TestALSAAudiobutton = new TransButtonSetting();
    TestALSAAudiobutton->setLabel(tr("Test ALSA  Audio Settings"));
    lpalsa->addChild(TestALSAAudiobutton);
    lpalsa->addChild(LoadALSAbutton);

    TransLabelSetting *osslabel = new TransLabelSetting();
        osslabel->setValue("The real OSS! More information can be found at:");

    TransLabelSetting *osslabel1 = new TransLabelSetting();
        osslabel1->setValue("       http://www.opensound.com ");

    TransLabelSetting *AlsaLabel = new TransLabelSetting();
        AlsaLabel->setValue("The inferior and complicated soundsystem known as ALSA ");

// OSS GROUP
    SoundOSSsettings  *OSS = new SoundOSSsettings ;
    ConfigurationGroup* osssettings = new VerticalConfigurationGroup(false);
        osssettings->addChild(osslabel);
        osssettings->addChild(osslabel1);
        osssettings->addChild(OSS);
        osssettings->addChild(syncboxes);
        osssettings->addChild(lp);
    connect(this, SIGNAL(oss_sig()),
        OSS,   SLOT(soundossgathersettings()));
    connect(TestAudiobutton, SIGNAL(pressed()),
        this,   SLOT(soundossgathersettings_1()));
    connect(LoadOSSbutton, SIGNAL(pressed()),
            OSS,   SLOT(loadossdriver()));

// ALSA GROUP
    SoundALSAsettings  *ALSA = new SoundALSAsettings ;
    ConfigurationGroup* alsasettings = new VerticalConfigurationGroup(false);
    alsasettings->addChild(AlsaLabel);
    alsasettings->addChild(ALSA);
    alsasettings->addChild(syncboxes);
    alsasettings->addChild(lpalsa);

    connect(this, SIGNAL(alsa_sig()),
            ALSA,   SLOT(soundalsagathersettings()));
    connect(TestALSAAudiobutton, SIGNAL(pressed()),
            this,   SLOT(soundalsagathersettings_1()));
    connect(LoadALSAbutton, SIGNAL(pressed()),
            ALSA,   SLOT(loadalsadriver()));
    addTarget("ALSA", alsasettings);
    addTarget("OSS", osssettings);
    addTarget("tinker", new VerticalConfigurationGroup(false));
};


SoundOSSsettings::SoundOSSsettings():
    TriggeredConfigurationGroup(true,false,true,true,true,true,true,true)
{
    SetVertical(true);
    HostSoundTypeout = new HostComboBox("HostSoundTypeout");
    HostSoundTypeout->setLabel(QObject::tr("Type"));
    HostSoundTypeout->addSelection("Analog");
    HostSoundTypeout->addSelection("Digital");
    HostSoundTypeout->setHelpText(QObject::tr(""));

    HostSoundOssAnalog = new HostComboBox("HostSoundOssAnalog");
    HostSoundOssDigital = new HostComboBox("HostSoundOssDigital");
    fillossselection();
    int findossanalog=HostSoundOssAnalog->findSelection(hostparm.OLDHostSoundOSSAnalog );
    int findossdigital=HostSoundOssDigital->findSelection(hostparm.OLDHostSoundOSSDigital );
    HostSoundOssAnalog->setValue(findossanalog);
    HostSoundOssDigital->setValue(findossdigital);
    addChild(HostSoundTypeout);
    setTrigger(HostSoundTypeout);
    addTarget("Analog", HostSoundOssAnalog);
    addTarget("Digital", HostSoundOssDigital);
};

SoundALSAsettings::SoundALSAsettings():
        TriggeredConfigurationGroup(true,false,true,true,true,true,true,true)
        {
            SetVertical(true);
            HostSoundALSATypeout = new HostComboBox("HostSoundALSATypeout");
            HostSoundALSATypeout->setLabel(QObject::tr("Type"));
            HostSoundALSATypeout->addSelection("Analog");
            HostSoundALSATypeout->addSelection("Digital");
            HostSoundALSATypeout->setHelpText(QObject::tr(""));

            HostSoundALSAAnalog = new HostComboBox("HostSoundALSAAnalog");
            HostSoundALSADigital = new HostComboBox("HostSoundALSADigital");
            fillALSAselection();
            int findalsaanalog=HostSoundALSAAnalog->findSelection(hostparm.OLDHostSoundALSAAnalog );
            int findalsadigital=HostSoundALSADigital->findSelection(hostparm.OLDHostSoundALSADigital );
            HostSoundALSAAnalog->setValue(findalsaanalog);
            HostSoundALSADigital->setValue(findalsadigital);
            addChild(HostSoundALSATypeout);
            setTrigger(HostSoundALSATypeout);
            addTarget("Analog", HostSoundALSAAnalog);
            addTarget("Digital", HostSoundALSADigital);
        };

void  SoundOSSsettings::loadossdriver()
{
    cout << "oss button pressed" << endl;

// Add info popup right here
    QString cmdtxt;
    cmdtxt="sudo ";
    cmdtxt.append(MV_ROOT) ;
//    cmdtxt=MV_ROOT  ;
    cmdtxt.append("bin/soundconfig.sh -t LOAD  -i OSS &");
    system(cmdtxt);
    int return_code = 0;
    QString msgtext = "Loading OSS driver" ;

    MythBusyDialog *busy = new MythBusyDialog(msgtext);
    // yet another incorrect way todo things, but I don't know anybetter
    // as long as ps can find systemconfig in the list  the busy box will appear and update
    busy->start();
    while (  return_code == 0 )
    {
        return_code = myth_system("ps -ef|grep soundconfig.sh|grep -v grep > /dev/null");
        qApp->processEvents ();
        usleep(900);
    }
    busy->Close();
    busy->deleteLater();
    fillossselection();

}
void  SoundALSAsettings::loadalsadriver()
{
    cout << "Loading alsa driver" << endl;
    QString cmdtxt;
    cmdtxt="sudo ";
    cmdtxt.append(MV_ROOT) ;
    cmdtxt.append("bin/soundconfig.sh -t LOAD  -i ALSA &");
    system(cmdtxt);
    int return_code = 0;
    QString msgtext = "Loading ALSA driver" ;

    MythBusyDialog *busy = new MythBusyDialog(msgtext);
    // yet another incorrect way todo things, but I don't know anybetter
    // as long as ps can find systemconfig in the list  the busy box will appear and update
    busy->start();
    while (  return_code == 0 )
    {
        return_code = myth_system("ps -ef|grep soundconfig.sh|grep -v grep > /dev/null");
        qApp->processEvents ();
        usleep(900);
    }
    busy->Close();
    busy->deleteLater();
    HostSoundALSAAnalog-> clearSelections();
    HostSoundALSADigital-> clearSelections();

    fillALSAselection();

}
void  SoundOSSsettings::fillossselection()
{
    myth_system("ossinfo -v1 -a |grep device > /tmp/ossdevices");
    QString currentitem;
    QString currentfile = "/tmp/ossdevices";
    QString line;
    QString legacy_device;
    QString simpleitem;
    QString currentitemtext;
    QRegExp sep( "\t"   );
    QFile file(currentfile);
    QString ossfound="false";
    HostSoundOssAnalog->clearSelections();
    HostSoundOssDigital-> clearSelections();


    if ( file.open(IO_ReadOnly | IO_Translate) )
    {
        QTextStream t( &file );        // use a text stream
        while ( !t.eof() )
        {
            line = t.readLine();
            if (line.contains("device index") )
            {
                legacy_device = t.readLine();
                legacy_device= legacy_device.section( "/",2,2);
                currentitemtext=line.section( "/" , 0 ,0 );
                simpleitem = currentitemtext.simplifyWhiteSpace();
                simpleitem = simpleitem.remove ( "(" );
                simpleitem = simpleitem.remove ( ")" );
                simpleitem.append(" (");
                simpleitem.append(legacy_device);
                simpleitem.append(")");
                if (line.contains("spdout") || line.contains("digital") )
                    HostSoundOssDigital->addSelection(simpleitem);
                else
                    HostSoundOssAnalog->addSelection(simpleitem);
                ossfound="true";
            }
        }
        if (ossfound=="false")
        {
            simpleitem="No cards found, try loading the OSS drivers";
            HostSoundOssAnalog->addSelection(simpleitem);
            HostSoundOssDigital->addSelection(simpleitem);
        }
    }
return ;
};


void  SoundALSAsettings::fillALSAselection()
{
    HostSoundALSAAnalog-> clearSelections();
    HostSoundALSADigital-> clearSelections();
    myth_system("aplay -l > /tmp/alsadevices");
    QString currentfile = "/tmp/alsadevices";
    QString line;
    QString hwdevice;
    QString alsadescription;
    QString temphwdevice;
    QString simpleitem;
    QFile file(currentfile);
    if ( file.open(IO_ReadOnly | IO_Translate) )
    {
        QTextStream t( &file );        // use a text stream
        while ( !t.eof() )
        {
            line = t.readLine();
            if (line.startsWith("card") )
            {
                if (line.contains("snd_ctl_card_info"))
                {
                    simpleitem="Try loading the alsa drivers";
                    HostSoundALSAAnalog->addSelection(simpleitem);
                    HostSoundALSADigital->addSelection(simpleitem);
                    break;
                }
                //card 0: I82801DBICH4 [Intel 82801DB-ICH4], device 0: Intel ICH [Intel 82801DB-ICH4]
                alsadescription=line.section( "," , 0 ,0 );
                alsadescription=alsadescription.section(":",1,1);
                hwdevice=line.section( ":" , 0 ,0 );
                hwdevice=hwdevice.section( " " , -1,-1 );
                //grabbing 2nd half of device
                temphwdevice=line.section(",",1,1);
                temphwdevice=temphwdevice.section(":",0,0);
                temphwdevice=temphwdevice.section(" ",-1,-1 );
                hwdevice.append(",");
                hwdevice.append(temphwdevice);
                simpleitem=alsadescription + "(hw:" + hwdevice + ")";
                if (line.contains("IEC958") )
                    HostSoundALSADigital->addSelection(simpleitem);
                else
                    HostSoundALSAAnalog->addSelection(simpleitem);
            }
        }
    }
return ;

}

void SoundSettings::soundossgathersettings_1 (void)
{
    hostparm.ThisHostAudiotype = HostAudiotype->getValue();
    hostparm.ThisHostsyncXine = HostsyncXine->getValue();
    hostparm.ThisHostsyncMplayer = HostsyncMplayer->getValue();
    hostparm.ThisHostsyncMythMusic = HostsyncMythMusic->getValue();
    hostparm.ThisHostsyncMythFrontend = HostsyncMythFrontend->getValue();
    // emit the signal to call soundossgathersetting.
    emit oss_sig();
};
void SoundSettings::soundalsagathersettings_1 (void)
{
    hostparm.ThisHostAudiotype = HostAudiotype->getValue();
    hostparm.ThisHostsyncXine = HostsyncXine->getValue();
    hostparm.ThisHostsyncMplayer = HostsyncMplayer->getValue();
    hostparm.ThisHostsyncMythMusic = HostsyncMythMusic->getValue();
    hostparm.ThisHostsyncMythFrontend = HostsyncMythFrontend->getValue();
    // emit the signal to call soundALSAgathersetting.
    emit alsa_sig();
};


void SoundOSSsettings::soundossgathersettings(void)
{
    hostparm.ThisHostSoundTypeout =  HostSoundTypeout->getValue() ;
    hostparm.ThisHostSoundOSSAnalog = HostSoundOssAnalog->getValue();
    hostparm.ThisHostSoundOSSDigital = HostSoundOssDigital->getValue();
    QString tempdevice;
    if  ( hostparm.ThisHostSoundTypeout == "Analog" )
    {
        tempdevice  =  hostparm.ThisHostSoundOSSAnalog ;
    }
    else
    {
        tempdevice = hostparm.ThisHostSoundOSSDigital ;
    };
    tempdevice = tempdevice.section( "(", 1,1 );
    tempdevice = tempdevice.section( ")", 0,0 );
    hostparm.ThisHostSoundDevice = "/dev/";
    hostparm.ThisHostSoundDevice.append(tempdevice);
    // Add info popup right here
    QString cmdtxt;
    cmdtxt=MV_ROOT  ;
    cmdtxt.append("bin/soundconfig.sh -t test  -i OSS -d " +  hostparm.ThisHostSoundDevice + "&");
    system(cmdtxt);
    int return_code = 0;
    QString msgtext = "Playing sample audio" ;
    MythBusyDialog *busy = new MythBusyDialog(msgtext);
    // yet another incorrect way todo things, but I don't know anybetter
    // as long as ps can find systemconfig in the list  the busy box will appear and update
    busy->start();
    while (  return_code == 0 )
    {
        return_code = myth_system("ps -ef|grep soundconfig.sh|grep -v grep > /dev/null");
        qApp->processEvents ();
        usleep(900);
    }
    busy->Close();
    busy->deleteLater();
};

void SoundALSAsettings::soundalsagathersettings(void)
{

    hostparm.ThisHostSoundALSATypeout =  HostSoundALSATypeout->getValue() ;
    hostparm.ThisHostSoundALSAAnalog = HostSoundALSAAnalog->getValue();
    hostparm.ThisHostSoundALSADigital = HostSoundALSADigital->getValue();
//     cout << hostparm.ThisHostSoundALSATypeout << endl;
//     cout << hostparm.ThisHostSoundALSAAnalog << endl;
//     cout << hostparm.ThisHostSoundALSADigital << endl;

    //  Intel [HDA Intel](hw:0,0)

//     cout << "--------" << endl;
    QString tempdevice;
    if  ( hostparm.ThisHostSoundALSATypeout == "Analog" )
    {
        tempdevice  =  hostparm.ThisHostSoundALSAAnalog ;
    }
    else
    {
        tempdevice = hostparm.ThisHostSoundALSADigital ;
    };
    tempdevice = tempdevice.section( "(", 1,1 );
    tempdevice = tempdevice.section( ")", 0,0 );
    hostparm.ThisHostSoundDevice = tempdevice;
    // Add info popup right here
    QString cmdtxt;
    cmdtxt=MV_ROOT  ;
    cmdtxt.append("bin/soundconfig.sh -t test  -i ALSA -d " +  hostparm.ThisHostSoundDevice + "&");
    system(cmdtxt);
    int return_code = 0;
    QString msgtext = "Playing sample audio" ;

    MythBusyDialog *busy = new MythBusyDialog(msgtext);
    busy->start();
    while (  return_code == 0 )
    {
        return_code = myth_system("ps -ef|grep soundconfig.sh|grep -v grep > /dev/null");
        qApp->processEvents ();
        usleep(900);
    }
    busy->Close();
    busy->deleteLater();
};


/* __________________________ END OF CLASSES_________________________*/

void pre_writesettings ()
{
    hostparm.ThisSystemType = gContext->GetSetting("HostSystemType");
    hostparm.ThisDBhost = gContext->GetSetting("HostMysqlServer");
    hostparm.ThisHostName   	= gContext->GetSetting("HostMyhostname");

    if  ( hostparm.ThisSystemType == "Standalone" )
    {
            hostparm.ThisDBhost = "localhost" ;
            hostparm.ThisRunfrontend = "1" ;
            gContext->SaveSetting("HostRunFrontend", hostparm.ThisRunfrontend );
        // disable pkgmirror
            hostparm.ThisHostPKG_MIRROR = "0";
            gContext->SaveSetting("GlobalPKG_MIRROR", hostparm.ThisHostPKG_MIRROR );
            hostparm.ThisHostServiceHobbit = gContext->GetSetting("GlobalServiceHobbitserver");
            if (hostparm.ThisHostServiceHobbit == "" )
            {
                hostparm.ThisHostServiceHobbit = "1";
                 QString s = "GlobalServiceHobbitserver";
                 gContext->SaveSettingOnHost(s, hostparm.ThisHostServiceHobbit ,NULL);
            }
    }
    else if  (hostparm.ThisSystemType == "Master_backend" )
    {
            if ( hostparm.ThisNFS =="" &&  gContext->GetSetting("HostServiceNFS")  == "" )
            {
                hostparm.ThisNFS = "1";
                gContext->SaveSetting("HostServiceNFS",hostparm.ThisNFS );
            }
            hostparm.ThisDBhost = "127.0.0.1" ;
            //GlobalPKG is only an option for MBE
            hostparm.ThisHostPKG_MIRROR = (gContext->GetSetting("GlobalPKG_MIRROR")) ;
            hostparm.ThisHostServiceHobbit = gContext->GetSetting("GlobalServiceHobbitserver");
            if (hostparm.ThisHostServiceHobbit == "" )
            {
                hostparm.ThisHostServiceHobbit = "1";
                 QString s = "GlobalServiceHobbitserver";
                 gContext->SaveSettingOnHost(s, hostparm.ThisHostServiceHobbit,NULL );
            }
    }
    else if  (hostparm.ThisSystemType == "Frontend_only" )
    {
            hostparm.ThisRunfrontend     = "1" ;
            hostparm.ThisSamba    = "0";
            hostparm.ThisNFS       = "0";
            hostparm.ThisMythWEB         = "0";
            gContext->SaveSetting("HostRunFrontend",  hostparm.ThisRunfrontend );
            gContext->SaveSetting("HostServiceSamba", hostparm.ThisSamba );
            gContext->SaveSetting("HostServiceNFS",  hostparm.ThisNFS );
            gContext->SaveSetting("HostServiceMythWEB",hostparm.ThisMythWEB );
            // if GBL is enabled, then check for host setting, else disable it
            if ( (gContext->GetSetting("GlobalPKG_MIRROR") ) == "1"  )
            {
                hostparm.ThisHostPKG_MIRROR     = gContext->GetSetting("HostPKG_MIRROR");
            }
            else
            {
                hostparm.ThisHostPKG_MIRROR = "0";
            };
//             cout << "install_hobbit:" <<endl;
//             cout << install_hobbit << endl;
//             cout <<"-----------------"<< endl;
            if ( ((gContext->GetSetting("GlobalServiceHobbitserver") ) == "1") || install_hobbit )
            {
                hostparm.ThisHostServiceHobbit = gContext->GetSetting("HostServiceHobbitclient");
//                 cout <<"might install hobbit!" << endl;
                cout <<  hostparm.ThisHostServiceHobbit << endl;

            }
            else
            {
                    hostparm.ThisHostServiceHobbit = "0";
                    cout <<" don't install hobbit" << endl;
            }

        gContext->SaveSetting("HostPKG_MIRROR",   hostparm.ThisHostPKG_MIRROR );
        gContext->SaveSetting("HostServiceHobbitclient",   hostparm.ThisHostServiceHobbit);

    }
    else if  (hostparm.ThisSystemType == "Slave_backend" )
    {
            hostparm.ThisSamba      	 = "0";
            hostparm.ThisNFS        	 = "0";
            hostparm.ThisMythWEB         = "0";
            gContext->SaveSetting("HostServiceSamba", hostparm.ThisSamba );
            gContext->SaveSetting("HostServiceNFS",  hostparm.ThisNFS );
            gContext->SaveSetting("HostServiceMythWEB",hostparm.ThisMythWEB );
            if ( (gContext->GetSetting("GlobalPKG_MIRROR") ) == "1"  )
            {
                hostparm.ThisHostPKG_MIRROR     = gContext->GetSetting("HostPKG_MIRROR");
            }
            else
            {
                hostparm.ThisHostPKG_MIRROR = "0";
            }
            if ( ((gContext->GetSetting("GlobalServiceHobbitserver") ) == "1") || install_hobbit )
            {
                hostparm.ThisHostServiceHobbit = gContext->GetSetting("HostServiceHobbitclient");
            }
            else
            {

                hostparm.ThisHostServiceHobbit = "0";
            }

            gContext->SaveSetting("HostPKG_MIRROR",   hostparm.ThisHostPKG_MIRROR );
            gContext->SaveSetting("HostServiceHobbitclient",   hostparm.ThisHostServiceHobbit);

    };

    if ( hostparm.ThisHostDefaultInterface == "" )
    {
    if ( gContext->GetSetting("HostDefaulteth0") == "1" )
            hostparm.ThisHostDefaultInterface = "eth0";
    else if ( gContext->GetSetting("HostDefaulteth1") == "1" )
            hostparm.ThisHostDefaultInterface = "eth1";
    else if ( gContext->GetSetting("HostDefaultwlan0") == "1" )
            hostparm.ThisHostDefaultInterface = "wlan0";
    else if ( gContext->GetSetting("HostDefaultwlan1") == "1" )
            hostparm.ThisHostDefaultInterface = "wlan1";
    else if ( gContext->GetSetting("HostActiveonbooteth0") == "1" )
            hostparm.ThisHostDefaultInterface = "eth0";
    else if ( gContext->GetSetting("HostActiveonbooteth1") == "1" )
            hostparm.ThisHostDefaultInterface = "eth1";
    else if ( gContext->GetSetting("HostActiveonbootwlan0") == "1" )
            hostparm.ThisHostDefaultInterface = "wlan0";
    else if ( gContext->GetSetting("HostActiveonbootwlan1") == "1" )
            hostparm.ThisHostDefaultInterface = "wlan1";
    else
            hostparm.ThisHostDefaultInterface = "ack";
    }
// Even after all the above, it's still possible to set the Default interface to one that isn't active.

    hostparm.ThisDBhost =  hostparm.ThisDBhost.section( "\t", 0, 0 );
    //remove spaces from hostname
    std::string s = hostparm.ThisHostName;
    std::string::iterator it = std::remove_if(s.begin(), s.end(), std::bind2nd(std::equal_to<char>(), ' '));
    s = std::string(s.begin(), it);
    hostparm.ThisHostName = s;
    if  ( hostparm.ThisHostName == "" )
    {
        hostparm.ThisHostName=gContext->GetHostName();
        std::string s = hostparm.ThisHostName;
        std::string::iterator it = std::remove_if(s.begin(), s.end(), std::bind2nd(std::equal_to<char>(), ' '));
        s = std::string(s.begin(), it);
        hostparm.ThisHostName = s;
        if ( hostparm.ThisHostName == "" )
                hostparm.ThisHostName = "You_Fool";
    }
    // piece togther the timezone
    QString tz;
    QString tregion;
    QString tsubregion;

    tz=gContext->GetSetting("HostTimeZone");

    cout << "tz extracted from database: " << tz << endl;
    if ( tz.isEmpty() || (tz == "Unknown"))
      timezone_unknown = TRUE;

    tregion=gContext->GetSetting("HostTimeZoneRegion");
    tsubregion=gContext->GetSetting("HostTimeZoneRegion_"+tregion);
    if ( tsubregion.isEmpty() )
        hostparm.ThisTimeZone  = tregion;
    else
        hostparm.ThisTimeZone  = tregion + "/" + tsubregion;

    cout << "hostparm.ThisTimeZone " << hostparm.ThisTimeZone  << endl;
    // save some settings  back to the datebase
    gContext->SaveSetting("HostMyhostname" , hostparm.ThisHostName );
    gContext->SaveSetting("HostMysqlserver", hostparm.ThisDBhost );
    gContext->SaveSetting("HostTimeZone", hostparm.ThisTimeZone );
}

void run_systemconfig(QString modulelist, bool restart, QString dbcommand)
{
    QString cmdtxt;
    cmdtxt="sudo ";
    cmdtxt.append(MV_ROOT) ;
    cmdtxt.append("bin/systemconfig.sh " + modulelist + " &");
    myth_system(cmdtxt);
    int return_code = 0;
    QString msgtext = "Please wait while  " ;
    msgtext.append(gContext->GetSetting("HostMyhostname"));
    msgtext.append(" is configured");
    MythBusyDialog *busy = new MythBusyDialog(msgtext);
    busy->start();
    while (  return_code == 0 )
    {
        return_code = myth_system("ps -ef|grep systemconfig.sh|grep -v grep > /dev/null");
        qApp->processEvents ();
        usleep(900);
    }
    busy->Close();
    busy->deleteLater();
    if  (restart)
    {
        return_code = 1;
        int loopnumber=0 ;
        bool doloop = true;
        MythBusyDialog *busy = new MythBusyDialog(
            QObject::tr("Transferring database settings"));
        // yet another incorrect way todo things, but I don't know anybetter
        // as long as ps can find systemconfig in the list  the busy box will appear and update
        busy->start();
        while (  doloop )
        {
            return_code = myth_system(dbcommand);
            qApp->processEvents ();
            usleep(100);
            loopnumber++ ;
            if  ( return_code == 0 || loopnumber >= 20000000 )
                doloop=false;
            cout << loopnumber << endl;
        }
        busy->Close();
        busy->deleteLater();
    };



}



int runsettings (bool mysqlonly , bool shownetwork , bool showhostype, bool showmisc , bool showshutdown, bool showadvanced,bool showsound,bool showadvancedX, bool showaccesscontrol, bool showplugins , bool showuser , bool showwebuser , bool showddns , bool showinfrared , bool showscreensaver )
{
        displaymysqlonly = false ;
        displayshownetwork =false ;
        displayshowhostype = false ;
        displayshowmisc =false ;
        displayshowshutdown =false ;
        displayshowadvanced = false;
        displayshowsound = false ;
        displayshowadvancedX = false;
        displayaccesscontrol= false;
        displayplugins= false;
        displayuser = false;
        displaywebuser = false;
        displayddns = false;
        displayinfrared = false;
        displayscreensaver = false;

        gContext->ActivateSettingsCache(true);
        gContext->ClearSettingsCache();
        bool  runothers=false;
        bool continuerun=true;
        int retc = 0 ;
        displaymysqlonly = mysqlonly;

        if (displaymysqlonly )
        {
            MythInstallSettings mysqlsettings;
            mysqlsettings.load();
            mysqlsettings.save();
            if ( mysqlsettings.exec() == QDialog::Accepted )
            {
                retc = 1;
            }
            else
            {
                retc=2;
            };
        };

        if ( shownetwork )
        {
            displayshownetwork = shownetwork;
            MythInstallSettings settings;
            settings.load();
            settings.save();
            if ( settings.exec() == QDialog::Accepted )
                {
                retc = 1;
                }
                else
                {
                    continuerun=false;
                    retc=2;
                };
            displayshownetwork = false;
        };

        if (   showhostype && continuerun )
        {
            displayshowhostype = showhostype;
            system ("avahi-browse -l -r  -t  _mysql._tcp > /tmp/mysqllist");
            MythInstallSettings settings1;
            settings1.load();
            settings1.save();
            if ( settings1.exec() == QDialog::Accepted )
            {
                retc = 1;
            }
            else
            {
                continuerun=false;
                retc=2;
            };
            displayshowhostype=false;
        }

        if ( showmisc  ||  showshutdown || showsound   || showadvancedX || showadvanced || showaccesscontrol || showplugins || showuser || showwebuser || showddns || showinfrared || showscreensaver )
        {
            runothers=true;
            displayshowmisc = showmisc;
            displayshowshutdown = showshutdown;
            displayshowadvanced = showadvanced;
            displayshowsound = showsound;
            displayshowadvancedX = showadvancedX;
            hostparm.displayshowadvancedX=showadvancedX;
            displayaccesscontrol = showaccesscontrol ;
            displayplugins = showplugins;
            displayuser = showuser;
            displaywebuser = showwebuser;
            displayddns = showddns ;
            displayinfrared = showinfrared;
            displayscreensaver = showscreensaver;

            if (displayshowadvancedX)
            {
                ReadDDCvalues();
            }
        };


    if ( runothers && continuerun )
        {
        //do I need this prewerite?
        pre_writesettings();
        DatabaseParams params = gContext->GetDatabaseParams();
        QString cmdtxt=MV_ROOT  ;
        cmdtxt.append("bin/timezip.py -m ");
        QString zipcommand=cmdtxt;
        zipcommand.append(hostparm.ThisDBhost);
        zipcommand.append("  -d " + params.dbHostName );
        cout << zipcommand << endl;
        myth_system(zipcommand);
        hostparm.ThisHostZipcode        = gContext->GetSetting("HostZipcode");
        hostparm.ThisTimeZone           = gContext->GetSetting("HostTimeZone");
        hostparm.ThisHostServiceHobbit  = gContext->GetSetting("HostServiceHobbitclient");
        if  ( hostparm.ThisHostServiceHobbit == "1" )
            install_hobbit = true;
/*
        cout << "install_hobbit:" <<endl;
        cout << install_hobbit << endl;
        cout <<"-----------------"<< endl; */

        MythInstallSettings settings2;
        settings2.load();
        settings2.save();
        gContext->SaveSetting("HostServiceHobbitclient", hostparm.ThisHostServiceHobbit );
        if ( settings2.exec() == QDialog::Accepted )
            {
                retc = 1;
                cout <<"i should save my settings(2)" << endl;
            }
            else
            {
                continuerun=false;
                retc=2;
                cout <<"no save for settings2 " << endl;
            };
        };
        pre_writesettings();
        if ( mysqlonly )
        {
            QString cmdtxt;
            cmdtxt=MV_ROOT  ;
            cmdtxt.append("bin/systemconfig.sh Mysql_only " +  hostparm.ThisDBhost);
            myth_system(cmdtxt);
        }
        else
        {
            if (retc == 1)
                writesettings();
        }
        return retc;
};



void writesettings ()
{
        ofstream myfile;
        hostparm.ThisHostName   	= gContext->GetSetting("HostMyhostname");
        hostparm.ThisHostDHCPhostname   = gContext->GetSetting("HostDHCPhostname");
        //hostparm.ThisTimeZone       = gContext->GetSetting("HostTimeZone");
        hostparm.ThisHostIP  		= gContext->GetSetting("HostIP");
        hostparm.ThisNETMASK       	= gContext->GetSetting("HostNETMASK");
        hostparm.ThisGW		        = gContext->GetSetting("HostGW");
        hostparm.ThisDNS	        = gContext->GetSetting("HostDNS");
        hostparm.ThisDHCP              = gContext->GetSetting("HostUseDHCP");

        //hostparm.ThisHostDefaultInterface=gContext->GetSetting("HostDefaultInterface");

        hostparm.ThisHostIPeth0         =  gContext->GetSetting("HostIPeth0");
        hostparm.ThisHostNETMASKeth0    =  gContext->GetSetting("HostNETMASKeth0");
        hostparm.ThisHostDNSeth0        =  gContext->GetSetting("HostDNSeth0");
        hostparm.ThisHostUSEDHCPeth0    =  gContext->GetSetting("HostUseDHCPeth0");
        hostparm.ThisHostGWeth0         =  gContext->GetSetting("HostGWeth0");
        hostparm.ThisHostActiveonbooteth0  =  gContext->GetSetting("HostActiveonbooteth0");
        hostparm.ThisHOSTESSIDeth0      =  gContext->GetSetting("HOSTESSIDeth0");
        hostparm.ThisHostUseEncryptioneth0 = gContext->GetSetting("HostUseEncryptioneth0");
        hostparm.ThisHostkeyeth0           = gContext->GetSetting("Hostkeyeth0");
        hostparm.ThisHostMTUeth0        = gContext->GetSetting("HostMTUeth0");

        hostparm.ThisHostIPeth1         =  gContext->GetSetting("HostIPeth1");
        hostparm.ThisHostNETMASKeth1    =  gContext->GetSetting("HostNETMASKeth1");
        hostparm.ThisHostDNSeth1        =  gContext->GetSetting("HostDNSeth1");
        hostparm.ThisHostUSEDHCPeth1    =  gContext->GetSetting("HostUseDHCPeth1");
        hostparm.ThisHostGWeth1         =  gContext->GetSetting("HostGWeth1");
        hostparm.ThisHostActiveonbooteth1  =  gContext->GetSetting("HostActiveonbooteth1");
        hostparm.ThisHOSTESSIDeth1      =  gContext->GetSetting("HOSTESSIDeth1");
        hostparm.ThisHostUseEncryptioneth1 = gContext->GetSetting("HostUseEncryptioneth1");
        hostparm.ThisHostkeyeth1           = gContext->GetSetting("Hostkeyeth1");
        hostparm.ThisHostMTUeth1        = gContext->GetSetting("HostMTUeth1");

        hostparm.ThisHostIPwlan0         =  gContext->GetSetting("HostIPwlan0");
        hostparm.ThisHostNETMASKwlan0    =  gContext->GetSetting("HostNETMASKwlan0");
        hostparm.ThisHostDNSwlan0        =  gContext->GetSetting("HostDNSwlan0");
        hostparm.ThisHostUSEDHCPwlan0    =  gContext->GetSetting("HostUseDHCPwlan0");
        hostparm.ThisHostGWwlan0         =  gContext->GetSetting("HostGWwlan0");
        hostparm.ThisHostActiveonbootwlan0  =  gContext->GetSetting("HostActiveonbootwlan0");
        hostparm.ThisHOSTESSIDwlan0      =  gContext->GetSetting("HOSTESSIDwlan0");
        hostparm.ThisHostUseEncryptionwlan0 = gContext->GetSetting("HostUseEncryptionwlan0");
        hostparm.ThisHostkeywlan0           = gContext->GetSetting("Hostkeywlan0");
        hostparm.ThisHostMTUwlan0        = gContext->GetSetting("HostMTUwlan0");

        hostparm.ThisHostIPwlan1         =  gContext->GetSetting("HostIPwlan1");
        hostparm.ThisHostNETMASKwlan1    =  gContext->GetSetting("HostNETMASKwlan1");
        hostparm.ThisHostDNSwlan1        =  gContext->GetSetting("HostDNSwlan1");
        hostparm.ThisHostUSEDHCPwlan1    =  gContext->GetSetting("HostUseDHCPwlan1");
        hostparm.ThisHostGWwlan1         =  gContext->GetSetting("HostGWwlan1");
        hostparm.ThisHostActiveonbootwlan1  =  gContext->GetSetting("HostActiveonbootwlan1");
        hostparm.ThisHOSTESSIDwlan1      =  gContext->GetSetting("HOSTESSIDwlan1");
        hostparm.ThisHostUseEncryptionwlan1 = gContext->GetSetting("HostUseEncryptionwlan1");
        hostparm.ThisHostkeywlan1           = gContext->GetSetting("Hostkeywlan1");
        hostparm.ThisHostMTUwlan1        = gContext->GetSetting("HostMTUwlan1");

        hostparm.ThisHostIPath0         =  gContext->GetSetting("HostIPath0");
        hostparm.ThisHostNETMASKath0    =  gContext->GetSetting("HostNETMASKath0");
        hostparm.ThisHostDNSath0        =  gContext->GetSetting("HostDNSath0");
        hostparm.ThisHostUSEDHCPath0    =  gContext->GetSetting("HostUseDHCPath0");
        hostparm.ThisHostGWath0         =  gContext->GetSetting("HostGWath0");
        hostparm.ThisHostActiveonbootath0  =  gContext->GetSetting("HostActiveonbootath0");
        hostparm.ThisHOSTESSIDath0      =  gContext->GetSetting("HOSTESSIDath0");
        hostparm.ThisHostUseEncryptionath0 = gContext->GetSetting("HostUseEncryptionath0");
        hostparm.ThisHostkeyath0           = gContext->GetSetting("Hostkeyath0");
        hostparm.ThisHostMTUath0        = gContext->GetSetting("HostMTUath0");


        hostparm.ThisHostServiceRRD = gContext->GetSetting("HostServiceRRD");
        hostparm.ThisSamba          = gContext->GetSetting("HostServiceSamba");
        hostparm.ThisHostServiceSamba_media = gContext->GetSetting("HostServiceSamba_media");
        hostparm.ThisHostServiceSamba_write = gContext->GetSetting("HostServiceSamba_write");
        hostparm.ThisHostServiceSamba_home = gContext->GetSetting("HostServiceSamba_home");
        hostparm.ThisHostServiceSamba_writehome = gContext->GetSetting("HostServiceSamba_writehome");
        hostparm.ThisHostServiceSamba_domain = gContext->GetSetting("HostServiceSamba_domain");
        hostparm.ThisNFS               	= gContext->GetSetting("HostServiceNFS");
        hostparm.ThisMythWEB    	       = gContext->GetSetting("HostServiceMythWEB");
        hostparm.ThisHostwebauth           = gContext->GetSetting("HOSTwebauth");

        hostparm.ThisHostRunDHCP =  gContext->GetSetting("HostRunDHCP");
        hostparm.ThisSystemType 	= gContext->GetSetting("HostSystemType");
        hostparm.ThisRemote     	       = gContext->GetSetting("HostRemoteType");
        hostparm.ThisHostLircWait      = gContext->GetSetting("HostLircWait");
      //  hostparm.ThisBlaster    	       = gContext->GetSetting("HostTransmitproto");
        hostparm.ThisReceiverType  	= gContext->GetSetting("HostReceiverType");
        hostparm.ThisHostSerialPortlirc = gContext->GetSetting("HostSerialPortlirc");
        hostparm.ThisHostUseEvrouter = gContext->GetSetting("HostRunEvrouter");
        hostparm.ThisHostEvrouterConfig = gContext->GetSetting("HostEvrouterConfig");
        hostparm.ThisXres     		= gContext->GetSetting("HostXres");
        hostparm.ThisAutodown		= gContext->GetSetting("HostAutodown");
        hostparm.ThisShutdowntime	= gContext->GetSetting("HostShutdownTime");
        hostparm.ThisShutdowntime2  = gContext->GetSetting("HostShutdownTime2");
        hostparm.ThisWakeuptime	= gContext->GetSetting("HostWakeupTime");
        hostparm.ThisUseNVRAM		= gContext->GetSetting("HostUseNVRAM");
        hostparm.ThisUseWOL		= gContext->GetSetting("HostUseWOL");
        hostparm.ThisKeepPackage	= gContext->GetSetting("HostKeepPackages");
        hostparm.ThisMythWelcome	= gContext->GetSetting("HostUseMythWelcome");
        hostparm.ThisHaveNFS            = gContext->GetSetting("HostHaveCentralNFS");
        hostparm.ThisNFSserver          = gContext->GetSetting("HostCentralNFSIP");
        hostparm.ThisNFSmountpoint      = gContext->GetSetting("HostNFSmountpoint");
        hostparm.ThisHostupdateplan     = gContext->GetSetting("Hostupdateplan");
        hostparm.ThisShowToolTips       = gContext->GetSetting("HostShowToolTips");
        hostparm.ThisRunfrontend        = gContext->GetSetting("HostRunFrontend");
        hostparm.ThisHostZipcode        = gContext->GetSetting("HostZipcode");
        hostparm.ThisHostncidClient     = gContext->GetSetting("HostncidClient");
        hostparm.ThisHostncidDaemon     = gContext->GetSetting("HostncidDaemon");
        hostparm.ThisHostSerialPortncid = gContext->GetSetting("HostSerialPortncid");
        hostparm.ThisHostbootsplash     = gContext->GetSetting("Hostbootsplash");

        hostparm.ThisXIgnoreConfig      =gContext->GetSetting("HostXIgnoreConfig");
        hostparm.ThisXcardtype          =gContext->GetSetting("HostXcardtype");
        hostparm.ThisXUseAdvanced       =gContext->GetSetting("HostXUseAdvanced");
        hostparm.ThisXIgnoreEDID        =gContext->GetSetting("HostXIgnoreEDID");
        hostparm.ThisXconnection        =gContext->GetSetting("HostXconnection");
        hostparm.ThisXDisplaysize       =gContext -> GetSetting("HostXDisplaysize");
        hostparm.ThisHostXNvidia1080p   =gContext -> GetSetting("HostXNvidia1080p");
        hostparm.ThisHostXNvidia1080i   =gContext -> GetSetting("HostXNvidia1080i");
        hostparm.ThisHostXNvidia720p    =gContext -> GetSetting("HostXNvidia720p");
        hostparm.ThisHostXNvidia480p    =gContext -> GetSetting("HostXNvidia480p");
//  EDID settings
        QString tempstring;
        tempstring = gContext->GetSetting("HostXHsyncLow");
        tempstring.append(" - ");
        tempstring.append(gContext->GetSetting("HostXHsyncHigh") );
        hostparm.ThisXHsync=tempstring;
        tempstring ="";
        tempstring=gContext->GetSetting("HostXVrefreshLow");
        tempstring.append(" - ");
        tempstring.append(gContext->GetSetting("HostXVrefreshHigh"));
        hostparm.ThisXVrefresh=tempstring;

//  Assemble the advanced modeline string
        QString modelinetype = gContext->GetSetting("HostXModelineCatagory");;
        QString tempmodeline = "HostXadvancedres" + modelinetype ;
        QString modeline    = gContext ->GetSetting(tempmodeline);
        hostparm.ThisXresadvanced = modelinetype +"_"+modeline;

//   Gather settings based on card type
        if ( hostparm.ThisXcardtype == "nVidia" )
        {
            hostparm.ThisXTVstandard = gContext->GetSetting("HostXnVidiaTVstandard");
            hostparm.ThisXTVconnection= gContext->GetSetting("HostXnVidiaTVformat");
            modelinetype = gContext->GetSetting("HostXNvidiaModelineCatagory");;
            tempmodeline = "HostXNvidiaadvancedres" + modelinetype ;
            modeline    = gContext ->GetSetting(tempmodeline);
            hostparm.ThisXresadvanced = modelinetype +"_"+modeline;
        }
        else if  ( hostparm.ThisXcardtype == "ATI" )
        {
            hostparm.ThisXTVstandard = gContext->GetSetting("HostXATITVstandard");
            hostparm.ThisXTVconnection= gContext->GetSetting("HostXati-tvformat");
        }


//*********************************************************************************************
// AUDIO SETTINGS
//******************************************************************************************
    hostparm.ThisHostAudiotype =  gContext ->GetSetting("HostAudiotype");
    hostparm.ThisHostsyncXine = gContext ->GetSetting("HostsyncXine");
    hostparm.ThisHostsyncMplayer = gContext ->GetSetting("HostsyncMplayer");
    hostparm.ThisHostsyncMythMusic = gContext ->GetSetting("HostsyncMythMusic");
    hostparm.ThisHostsyncMythFrontend = gContext ->GetSetting("HostsyncMythFrontend");
    hostparm.ThisHostSoundTypeout =  gContext ->GetSetting("HostSoundTypeout") ;
    hostparm.ThisHostSoundOSSAnalog = gContext ->GetSetting("HostSoundOssAnalog");
    hostparm.ThisHostSoundOSSDigital = gContext ->GetSetting("HostSoundOssDigital");
    hostparm.ThisHostSoundALSATypeout =  gContext ->GetSetting("HostSoundALSATypeout") ;
    hostparm.ThisHostSoundALSAAnalog = gContext ->GetSetting("HostSoundALSAAnalog");
    hostparm.ThisHostSoundALSADigital = gContext ->GetSetting("HostSoundALSADigital");

    if ( hostparm.ThisHostAudiotype  == "OSS"   )
    {
        QString tempdevice;
        QChar tempchar  ;
        hostparm.ThisHostSoundDevice = "/dev/dsp";
        if  ( hostparm.ThisHostSoundTypeout == "Analog" )
            tempdevice  =  hostparm.ThisHostSoundOSSAnalog ;

        if  ( hostparm.ThisHostSoundTypeout == "Digital" )
            tempdevice = hostparm.ThisHostSoundOSSDigital ;

        int tlength=(tempdevice.length()  -2 );
        if  ( tlength > 0  )
        {
            tempchar = tempdevice.at( tlength);
            hostparm.ThisHostSoundDevice.append(tempchar);
        };
    }


    if ( hostparm.ThisHostAudiotype  == "ALSA"   )
    {
        QString tempdevice;
        hostparm.ThisHostSoundTypeout = hostparm.ThisHostSoundALSATypeout;
        if (  hostparm.ThisHostSoundTypeout == "Digital" )
            tempdevice=hostparm.ThisHostSoundALSADigital;
        if (  hostparm.ThisHostSoundTypeout == "Analog" )
            tempdevice=hostparm.ThisHostSoundALSAAnalog;

        tempdevice = tempdevice.section( "(", 1,1 );
        tempdevice = tempdevice.section( ")", 0,0 );
        hostparm.ThisHostSoundDevice = tempdevice;
    }
// Turn off internal audio controls is digital audio is seleced
    if  ( hostparm.ThisHostSoundTypeout == "Digital" )
        gContext->SaveSetting("MythControlsVolume","0");

//  LCD TYPE
    hostparm.ThisHostLCDType = gContext ->GetSetting("HostLCDType");
    if  ( hostparm.ThisHostLCDType  != "no_lcd" && hostparm.ThisHostLCDType  != "tinker" && hostparm.ThisHostLCDType != "" )
    {
        // enable mythtv lcddevice
        gContext->SaveSetting("LCDEnable","1");
    };
// Backupsettings
        hostparm.ThisHostRemoteBackup = gContext ->GetSetting("HostRemoteBackup");
        hostparm.ThisHostRemoteBackupDir = gContext ->GetSetting("HostRemoteBackupDir");
//plugins
        hostparm.ThisHostpluginmytharchive = gContext->GetSetting("Hostpluginmytharchive");
        hostparm.ThisHostpluginmythbrowser = gContext->GetSetting("Hostpluginmythbrowser");
        hostparm.ThisHostpluginmythcontrols = gContext->GetSetting("Hostpluginmythcontrols");
        hostparm.ThisHostpluginmythflix = gContext->GetSetting("Hostpluginmythflix");
        hostparm.ThisHostpluginmythgallery = gContext->GetSetting("Hostpluginmythgallery");
        hostparm.ThisHostpluginmythgame = gContext->GetSetting("Hostpluginmythgame");
        hostparm.ThisHostpluginmythmovietime = gContext->GetSetting("Hostpluginmythmovietime");
        hostparm.ThisHostpluginmythmusic = gContext->GetSetting("Hostpluginmythmusic");
        hostparm.ThisHostpluginmythnews = gContext->GetSetting("Hostpluginmythnews");
        hostparm.ThisHostpluginmythphone = gContext->GetSetting("Hostpluginmythphone");
        hostparm.ThisHostpluginmythsmolt = gContext->GetSetting("Hostpluginmythsmolt");
        hostparm.ThisHostpluginmythvideo = gContext->GetSetting("Hostpluginmythvideo");
        hostparm.ThisHostpluginmythweather = gContext->GetSetting("Hostpluginmythweather");
        hostparm.ThisHostpluginmythzoneminder = gContext->GetSetting("Hostpluginmythzoneminder");
        hostparm.ThisHostpluginmythgameFceu = gContext->GetSetting("HostpluginmythgameFceu");
        hostparm.ThisHostpluginmythgameZsnes = gContext->GetSetting("HostpluginmythgameZsnes");
        hostparm.ThisHostpluginmythgameMame = gContext->GetSetting("HostpluginmythgameMame");
        hostparm.ThisHostpluginmythvideo_dvdcss = gContext->GetSetting("Hostpluginmythvideo_dvdcss");
        hostparm.ThisHostpluginmythappletrailers= gContext->GetSetting("Hostpluginmythappletrailers");
        hostparm.ThisHostpluginmythstream= gContext->GetSetting("Hostpluginmythstream");
        hostparm.ThisHostpluginmythvodka= gContext->GetSetting("Hostpluginmythvodka");
        hostparm.ThisHostMiro= gContext->GetSetting("HostMiro");
        hostparm.ThisHostpluginmythgameMednafen= gContext->GetSetting("HostpluginmythgameMednafen");
        hostparm.ThisHostpluginmythgameROMDB= gContext->GetSetting("HostpluginmythgameROMDB");
        hostparm.ThisHostXine = gContext->GetSetting("HostXine");
        hostparm.ThisHostwebmin = gContext->GetSetting("Hostwebmin");
        hostparm.ThisHostfuppes = gContext->GetSetting("Hostfuppes");
        hostparm.ThisHostfoldingathome = gContext->GetSetting("Hostfoldingathome");
        hostparm.ThisHostfoldingusername = gContext->GetSetting("Hostfoldingusername");
        hostparm.ThisHostfoldingworksize = gContext->GetSetting("Hostfoldingworksize");
        hostparm.ThisHostDDnslogin = gContext->GetSetting("HostDDnslogin");
        hostparm.ThisHostDDnspassword = gContext->GetSetting("HostDDnspassword");
        hostparm.ThisHostDDnshostname = gContext->GetSetting("HostDDnshostname");
        hostparm.ThisHostDDnsEnable = gContext->GetSetting("HostDDnsEnable");
        hostparm.ThisHostscreensavertype =  gContext->GetSetting("Hostscreensavertype");
        hostparm.ThisHostscreensaveridle = gContext->GetSetting("Hostscreensaveridle");
        if (gContext->GetSetting("HostScreensaverBlank") == "1" )
            hostparm.ThisHostscreensavertheme="Blank";
        else if (gContext->GetSetting("HostScreensaverRandom") == "1" )
            hostparm.ThisHostscreensavertheme="Random";
        else
        {
            if ( hostparm.ThisHostscreensavertype == "gscreensaver" )
                hostparm.ThisHostscreensavertheme = gContext->GetSetting("HostGScreensavertheme");
            if ( hostparm.ThisHostscreensavertype == "xscreensaver" )
                hostparm.ThisHostscreensavertheme = gContext->GetSetting("HostXScreensavertheme");
        }

        hostparm.ThisHostTransmitproto_1 =
            gContext->GetSetting("HostTransmitproto_1");
        hostparm.ThisHostTransmitproto_2 =
            gContext->GetSetting("HostTransmitproto_2");
        hostparm.ThisHostTransmitproto_3 =
            gContext->GetSetting("HostTransmitproto_3");
        hostparm.ThisHostTransmitproto_4 =
            gContext->GetSetting("HostTransmitproto_4");
        hostparm.ThisHostBlasterType =
            gContext->GetSetting("HostBlasterType");
        hostparm.ThisHostSerialPort_blasterlirc =
            gContext->GetSetting("HostSerialPort_blasterlirc");
        hostparm.ThisHostnumblaster = "1";
        if ( hostparm.ThisHostBlasterType == "CommandIR" )
            hostparm.ThisHostnumblaster = "4" ;
        if ( hostparm.ThisHostBlasterType == "MCE" )
            hostparm.ThisHostnumblaster = "2" ;
        hostparm.ThisHOSTrootSSH =  gContext->GetSetting("HOSTrootSSH");





//______________________WRITE OUT THE FILE__________________________
        QString systemheader;

        myfile.open ("/etc/systemconfig");
        myfile << "hostname=\""     + hostparm.ThisHostName + "\"\n";
        myfile << "dhcphostname=\"" + hostparm.ThisHostDHCPhostname + "\"\n";
        myfile << "timezone=\""     + hostparm.ThisTimeZone    	+ "\"\n";
        myfile << "ip=\""           + hostparm.ThisHostIP           + "\"\n";
        myfile << "netmask=\"" 		+ hostparm.ThisNETMASK    	+ "\"\n";
        myfile << "route=\"" 		+ hostparm.ThisGW               + "\"\n";
        myfile << "nameserver=\"" 	+ hostparm.ThisDNS        	+ "\"\n";

        myfile << "default_interface=\""    + hostparm.ThisHostDefaultInterface          + "\"\n";

        if ( hostparm.ThisHostActiveonbooteth0 == "1" )
        {
            systemheader= "\n#Network config for eth0 \n"  ;
            myfile << systemheader ;
            myfile << "Hostipeth0=\""   + hostparm.ThisHostIPeth0           + "\"\n";
            myfile << "Hostnetmasketh0=\""   +hostparm.ThisHostNETMASKeth0      + "\"\n";
            myfile << "HostDNSeth0=\""   +hostparm.ThisHostDNSeth0          + "\"\n";
            myfile << "HostUSEDHCPeth0=\""   +hostparm.ThisHostUSEDHCPeth0      + "\"\n";
            myfile << "HostGWeth0=\""   +hostparm.ThisHostGWeth0            + "\"\n";
            myfile << "HostActiveeth0=\""   +hostparm.ThisHostActiveonbooteth0      + "\"\n";
            myfile << "HostESSIDeth0=\"" + hostparm.ThisHOSTESSIDeth0  + "\"\n";
            myfile << "HostUseEncryptioneth0=\"" + hostparm.ThisHostUseEncryptioneth0 + "\"\n";
            myfile << "HostKeyeth0=\"" + hostparm.ThisHostkeyeth0         + "\"\n";
            myfile << "HOST_iswirelesseth0=\"" + hostparm.ThisHOST_iswirelesseth0         + "\"\n";
            myfile << "HostMTUeth0=\"" + hostparm.ThisHostMTUeth0         + "\"\n";
        }

        if ( hostparm.ThisHostActiveonbooteth1 == "1" )
        {
            systemheader= "\n#Network config for eth1 \n"  ;
            myfile << systemheader ;
            myfile << "Hostipeth1=\""   + hostparm.ThisHostIPeth1           + "\"\n";
            myfile << "Hostnetmasketh1=\""   +hostparm.ThisHostNETMASKeth1      + "\"\n";
            myfile << "HostDNSeth1=\""   +hostparm.ThisHostDNSeth1          + "\"\n";
            myfile << "HostUSEDHCPeth1=\""   +hostparm.ThisHostUSEDHCPeth1      + "\"\n";
            myfile << "HostGWeth1=\""   +hostparm.ThisHostGWeth1            + "\"\n";
            myfile << "HostActiveeth1=\""   +hostparm.ThisHostActiveonbooteth1      + "\"\n";
            myfile << "HostESSIDeth1=\"" + hostparm.ThisHOSTESSIDeth1  + "\"\n";
            myfile << "HostUseEncryptioneth1=\"" + hostparm.ThisHostUseEncryptioneth1 + "\"\n";
            myfile << "HostKeyeth1=\"" + hostparm.ThisHostkeyeth1         + "\"\n";
            myfile << "HOST_iswirelesseth1=\"" + hostparm.ThisHOST_iswirelesseth1         + "\"\n";
            myfile << "HostMTUeth1=\"" + hostparm.ThisHostMTUeth1         + "\"\n";
        }
        if ( hostparm.ThisHostActiveonbootwlan0 == "1" )
        {
            systemheader= "\n#Network config for wlan0 \n"  ;
            myfile << systemheader ;
            myfile << "Hostipwlan0=\""   + hostparm.ThisHostIPwlan0           + "\"\n";
            myfile << "Hostnetmaskwlan0=\""   +hostparm.ThisHostNETMASKwlan0      + "\"\n";
            myfile << "HostDNSwlan0=\""   +hostparm.ThisHostDNSwlan0          + "\"\n";
            myfile << "HostUSEDHCPwlan0=\""   +hostparm.ThisHostUSEDHCPwlan0      + "\"\n";
            myfile << "HostGWwlan0=\""   +hostparm.ThisHostGWwlan0            + "\"\n";
            myfile << "HostActivewlan0=\""   +hostparm.ThisHostActiveonbootwlan0      + "\"\n";
            myfile << "HostESSIDwlan0=\"" + hostparm.ThisHOSTESSIDwlan0  + "\"\n";
            myfile << "HostUseEncryptionwlan0=\"" + hostparm.ThisHostUseEncryptionwlan0 + "\"\n";
            myfile << "HostKeywlan0=\"" + hostparm.ThisHostkeywlan0         + "\"\n";
            myfile << "HOST_iswirelesswlan0=\"" + hostparm.ThisHOST_iswirelesswlan0         + "\"\n";
            myfile << "HostMTUwlan0=\"" + hostparm.ThisHostMTUwlan0         + "\"\n";
        }
        if ( hostparm.ThisHostActiveonbootwlan1 == "1" )
        {
            systemheader= "\n#Network config for wlan1 \n"  ;
            myfile << systemheader ;
            myfile << "Hostipwlan1=\""   + hostparm.ThisHostIPwlan1           + "\"\n";
            myfile << "Hostnetmaskwlan1=\""   +hostparm.ThisHostNETMASKwlan1      + "\"\n";
            myfile << "HostDNSwlan1=\""   +hostparm.ThisHostDNSwlan1          + "\"\n";
            myfile << "HostUSEDHCPwlan1=\""   +hostparm.ThisHostUSEDHCPwlan1      + "\"\n";
            myfile << "HostGWwlan1=\""   +hostparm.ThisHostGWwlan1            + "\"\n";
            myfile << "HostActivewlan1=\""   +hostparm.ThisHostActiveonbootwlan1      + "\"\n";
            myfile << "HostESSIDwlan1=\"" + hostparm.ThisHOSTESSIDwlan1  + "\"\n";
            myfile << "HostUseEncryptionwlan1=\"" + hostparm.ThisHostUseEncryptionwlan1 + "\"\n";
            myfile << "HostKeywlan1=\"" + hostparm.ThisHostkeywlan1         + "\"\n";
            myfile << "HOST_iswirelesswlan1=\"" + hostparm.ThisHOST_iswirelesswlan1         + "\"\n";
            myfile << "HostMTUwlan1=\"" + hostparm.ThisHostMTUwlan1         + "\"\n";
        }

      if ( hostparm.ThisHostActiveonbootath0 == "1" )
        {
            systemheader= "\n#Network config for ath0 \n"  ;
            myfile << systemheader ;
            myfile << "Hostipath0=\""   + hostparm.ThisHostIPath0           + "\"\n";
            myfile << "Hostnetmaskath0=\""   +hostparm.ThisHostNETMASKath0      + "\"\n";
            myfile << "HostDNSath0=\""   +hostparm.ThisHostDNSath0          + "\"\n";
            myfile << "HostUSEDHCPath0=\""   +hostparm.ThisHostUSEDHCPath0      + "\"\n";
            myfile << "HostGWath0=\""   +hostparm.ThisHostGWath0            + "\"\n";
            myfile << "HostActiveath0=\""   +hostparm.ThisHostActiveonbootath0      + "\"\n";
            myfile << "HostESSIDath0=\"" + hostparm.ThisHOSTESSIDath0  + "\"\n";
            myfile << "HostUseEncryptionath0=\"" + hostparm.ThisHostUseEncryptionath0 + "\"\n";
            myfile << "HostKeyath0=\"" + hostparm.ThisHostkeyath0         + "\"\n";
            myfile << "HOST_iswirelessath0=\"" + hostparm.ThisHOST_iswirelessath0         + "\"\n";
            myfile << "HostMTUath0=\"" + hostparm.ThisHostMTUath0         + "\"\n";
        }


        systemheader= "\n#Misc \n"  ;
        myfile << systemheader ;
        myfile << "UseSamba=\""		+ hostparm.ThisSamba      	+ "\"\n";
        myfile << "Samba_media=\"" +  hostparm.ThisHostServiceSamba_media + "\"\n";
        myfile << "Samba_mediareadonly=\"" +  hostparm.ThisHostServiceSamba_write + "\"\n";
        myfile << "Samba_home=\"" +  hostparm.ThisHostServiceSamba_home + "\"\n";
        myfile << "Samba_homereadonly=\"" +  hostparm.ThisHostServiceSamba_writehome + "\"\n";
        myfile << "Samba_domain=\"" + hostparm.ThisHostServiceSamba_domain + "\"\n";
        myfile << "UseHobbit=\"" +  hostparm.ThisHostServiceHobbit + "\"\n";
        myfile << "UseRRD=\"" +  hostparm.ThisHostServiceRRD + "\"\n";
        myfile << "UseNFS=\"" 		+ hostparm.ThisNFS             	+ "\"\n";
        myfile << "UseMythWEB=\"" 	+ hostparm.ThisMythWEB     	+ "\"\n";
        myfile << "UseMythWEB_auth=\""   + hostparm.ThisHostwebauth      + "\"\n";
        myfile << "UseDHCP=\"" 	 	+ hostparm.ThisDHCP          	+ "\"\n";
        myfile << "RunDHCP=\""      + hostparm.ThisHostRunDHCP             + "\"\n";
        myfile << "SystemType=\"" 	+ hostparm.ThisSystemType 	+ "\"\n";

        myfile << "UseEvrouter=\"" + hostparm.ThisHostUseEvrouter + "\"\n";
        myfile << "EvrouterConfig=\"" + hostparm.ThisHostEvrouterConfig + "\"\n";
        myfile << "dbhost=\""		+ hostparm.ThisDBhost         	+ "\"\n";
        myfile << "Xres=\"" 		+ hostparm.ThisXres             + "\"\n";
        myfile << "AutoShutdown=\""	+ hostparm.ThisAutodown		+ "\"\n";
        myfile << "Shutdowntime=\""	+ hostparm.ThisShutdowntime	+ "\"\n";
        myfile << "Shutdowntime2=\"" + hostparm.ThisShutdowntime2 + "\"\n";
        myfile << "Wakeuptime=\""	+ hostparm.ThisWakeuptime	+ "\"\n";
        myfile << "UseNVRAM=\""		+ hostparm.ThisUseNVRAM		+ "\"\n";
        myfile << "UseWOL=\""		+ hostparm.ThisUseWOL		+ "\"\n";
        myfile << "KeepPackages=\""	+ hostparm.ThisKeepPackage	+ "\"\n";
        myfile << "UseMythWelcome=\""	+ hostparm.ThisMythWelcome	+ "\"\n";
        myfile << "HaveCentralNFS=\""   + hostparm.ThisHaveNFS          + "\"\n";
        myfile << "NFSserver=\""        + hostparm.ThisNFSserver        + "\"\n";
        myfile << "NFSmount=\""         + hostparm.ThisNFSmountpoint    + "\"\n";
        myfile << "Hostupdateplan=\""   + hostparm.ThisHostupdateplan   + "\"\n";
        myfile << "ShowTips=\""         + hostparm.ThisShowToolTips     + "\"\n";
        myfile << "PKG_MIRROR=\""       + hostparm.ThisHostPKG_MIRROR   + "\"\n";
        myfile << "RunFrontend=\""      + hostparm.ThisRunfrontend      + "\"\n";
        myfile << "zipcode=\""          + hostparm.ThisHostZipcode + "\"\n";
        myfile << "ncidclient=\""       + hostparm.ThisHostncidClient + "\"\n";
        myfile << "Runncidd=\""        + hostparm.ThisHostncidDaemon +  "\"\n";
        myfile <<  "nciddSerialPort=\""      + hostparm.ThisHostSerialPortncid +  "\"\n";
        myfile << "Usebootsplash=\""        + hostparm.ThisHostbootsplash + "\"\n";
        myfile << "LCDtype=\"" + hostparm.ThisHostLCDType + "\"\n";
        myfile << "RemoteBackup=\"" + hostparm.ThisHostRemoteBackup + "\"\n";
        myfile << "RemoteBackupDir=\"" + hostparm.ThisHostRemoteBackupDir + "\"\n";


        systemheader= "\n#X display settings \n"  ;
        myfile << systemheader ;
        myfile << "XIgnoreConfig=\""        + hostparm.ThisXIgnoreConfig    + "\"\n";
        myfile << "Xcardtype=\""              + hostparm.ThisXcardtype     + "\"\n";
        myfile << "XUseAdvanced=\""       + hostparm.ThisXUseAdvanced + "\"\n";
        myfile << "XIgnoreEDID=\""         + hostparm.ThisXIgnoreEDID  + "\"\n";
        myfile << "Xconnection=\""           + hostparm.ThisXconnection  + "\"\n";
        myfile << "XHsync=\""                  + hostparm.ThisXHsync  + "\"\n";
        myfile << "XVrefresh=\""              + hostparm.ThisXVrefresh+ "\"\n";
        myfile << "Xresadvanced=\""        + hostparm.ThisXresadvanced + "\"\n";
        myfile << "XTVstandard=\""         +  hostparm.ThisXTVstandard +  "\"\n";
        myfile << "XTVconnection=\""      +  hostparm.ThisXTVconnection +  "\"\n";
        myfile << "XDisplaysize=\""         + hostparm.ThisXDisplaysize + "\"\n";
        myfile << "XnVidia1080p=\""         + hostparm.ThisHostXNvidia1080p+ "\"\n";
        myfile << "XnVidia1080i=\""         + hostparm.ThisHostXNvidia1080i+ "\"\n";
        myfile << "XnVidia720p=\""         + hostparm.ThisHostXNvidia720p+ "\"\n";
        myfile << "XnVidia480p=\""         + hostparm.ThisHostXNvidia480p+ "\"\n";

        systemheader= "\n#Audio settings\n"  ;
        myfile << systemheader ;
        myfile << "Audiotype=\""            + hostparm.ThisHostAudiotype + "\"\n";
        myfile << "Audiotypeout=\""            + hostparm.ThisHostSoundTypeout + "\"\n";
        myfile << "SoundDevice=\""    + hostparm.ThisHostSoundDevice+  "\"\n";
        myfile << "syncXine=\""   + hostparm.ThisHostsyncXine + "\"\n";
        myfile << "syncMplayer=\""   + hostparm.ThisHostsyncMplayer + "\"\n";
        myfile << "syncMythMusic=\""   + hostparm.ThisHostsyncMythMusic + "\"\n";
        myfile << "syncMythFrontend=\""   + hostparm.ThisHostsyncMythFrontend + "\"\n";


        systemheader= "\n#Software settings\n"  ;
        myfile << systemheader ;
        myfile << "mytharchive=\"" + hostparm.ThisHostpluginmytharchive + "\"\n";
        myfile << "mythbrowser=\"" + hostparm.ThisHostpluginmythbrowser + "\"\n";
        myfile << "mythcontrols=\"" + hostparm.ThisHostpluginmythcontrols + "\"\n";
        myfile << "mythflix=\"" + hostparm.ThisHostpluginmythflix + "\"\n";
        myfile << "mythgallery=\"" + hostparm.ThisHostpluginmythgallery + "\"\n";
        myfile << "mythgame=\"" + hostparm.ThisHostpluginmythgame + "\"\n";
        myfile << "mythmovietime=\"" + hostparm.ThisHostpluginmythmovietime + "\"\n";
        myfile << "mythmusic=\"" + hostparm.ThisHostpluginmythmusic + "\"\n";
        myfile << "mythnews=\"" + hostparm.ThisHostpluginmythnews + "\"\n";
        myfile << "mythphone=\"" + hostparm.ThisHostpluginmythphone + "\"\n";
        myfile << "mythsmolt=\"" + hostparm.ThisHostpluginmythsmolt + "\"\n";
        myfile << "mythvideo=\"" + hostparm.ThisHostpluginmythvideo + "\"\n";
        myfile << "mythweather=\"" + hostparm.ThisHostpluginmythweather + "\"\n";
        myfile << "mythzoneminder=\"" + hostparm.ThisHostpluginmythzoneminder + "\"\n";

        myfile << "fceu=\"" + hostparm.ThisHostpluginmythgameFceu + "\"\n";
        myfile << "zsnes=\"" + hostparm.ThisHostpluginmythgameZsnes + "\"\n";
        myfile << "mame=\"" + hostparm.ThisHostpluginmythgameMame + "\"\n";
        myfile << "dvdcss=\"" + hostparm.ThisHostpluginmythvideo_dvdcss + "\"\n";

        myfile << "mythappletrailers=\"" + hostparm.ThisHostpluginmythappletrailers + "\"\n";
        myfile << "mythstream=\"" + hostparm.ThisHostpluginmythstream + "\"\n";
        myfile << "mythvodka=\"" +hostparm.ThisHostpluginmythvodka + "\"\n";
        myfile << "miro=\"" + hostparm.ThisHostMiro + "\"\n";
        myfile << "mednafen=\"" + hostparm.ThisHostpluginmythgameMednafen + "\"\n";
        myfile << "romdb=\"" + hostparm.ThisHostpluginmythgameROMDB + "\"\n";
        myfile << "xine=\"" + hostparm.ThisHostXine  + "\"\n";
        myfile << "webmin=\"" + hostparm.ThisHostwebmin  + "\"\n";
        myfile << "fuppes=\"" + hostparm.ThisHostfuppes  + "\"\n";
        myfile << "foldingathome=\"" + hostparm.ThisHostfoldingathome  + "\"\n";
        myfile << "foldingusername=\"" + hostparm.ThisHostfoldingusername  + "\"\n";
        myfile << "foldingworksize=\"" + hostparm.ThisHostfoldingworksize  + "\"\n";



        myfile << "DDnslogin=\"" +     hostparm.ThisHostDDnslogin + "\"\n";
        myfile << "DDnspassword=\"" + hostparm.ThisHostDDnspassword + "\"\n";
        myfile << "DDnshostname=\"" +   hostparm.ThisHostDDnshostname + "\"\n";
        myfile << "DDnsEnable=\"" +    hostparm.ThisHostDDnsEnable + "\"\n";
        myfile << "Screensavertype=\"" + hostparm.ThisHostscreensavertype + "\"\n";
        myfile << "Screensaveridle=\"" + hostparm.ThisHostscreensaveridle + "\"\n";
        myfile << "Screensavertheme=\"" + hostparm.ThisHostscreensavertheme + "\"\n";

        systemheader="\n#IR settings\n"  ;
        myfile << systemheader ;
        myfile << "Remotetype=\""     + hostparm.ThisRemote       + "\"\n";
        //myfile << "Blastertype=\""  + hostparm.ThisBlaster      + "\"\n";
        myfile << "ReceiverType=\"" + hostparm.ThisReceiverType     + "\"\n";
        myfile << "HostLircWait=\"" + hostparm.ThisHostLircWait + "\"\n";
        myfile << "ReceiverSerialport=\"" + hostparm.ThisHostSerialPortlirc + "\"\n";
        myfile << "HostTransmitproto_1=\"" +  hostparm.ThisHostTransmitproto_1 + "\"\n";
        myfile << "HostTransmitproto_2=\"" +  hostparm.ThisHostTransmitproto_2 + "\"\n";
        myfile << "HostTransmitproto_3=\"" +  hostparm.ThisHostTransmitproto_3 + "\"\n";
        myfile << "HostTransmitproto_4=\"" +  hostparm.ThisHostTransmitproto_4 + "\"\n";

        myfile << "HostBlasterType=\"" + hostparm.ThisHostBlasterType + "\"\n";
        myfile << "HostSerialPort_blasterlirc=\"" +  hostparm.ThisHostSerialPort_blasterlirc + "\"\n";
        myfile << "Hostnumblaster=\"" + hostparm.ThisHostnumblaster + "\"\n";
        myfile << "rootSSH=\"" + hostparm.ThisHOSTrootSSH  + "\"\n";

    myfile.close();

}


MythInstallSettings::MythInstallSettings()
{
    VerticalConfigurationGroup* vcg =   new VerticalConfigurationGroup(false,false,true,true);
    VerticalConfigurationGroup* denied =  new VerticalConfigurationGroup(false,false,true,true);
    TransLabelSetting *deniedlabel = new TransLabelSetting();
    deniedlabel->setValue("                You do not have access to this screen  " );              denied->addChild(deniedlabel);
    if  ( displaymysqlonly  )
        {
            vcg->addChild(HostMysqlserverip_listbox());
            vcg->addChild(ThemePainter());
            addChild(vcg);
        }
        else
        {
            vcg->setLabel(QObject::tr("Host Settings"));
            // Check to see if screen should appear
            if ( displayshownetwork )
            {
            //Check to see if screen is allowed to appear
                if (  ((gContext->GetSetting("Hostaccessnetwork"))  == "0" )  )
                    {
                        denied ->setLabel(QObject::tr("Host Settings"));
                        addChild(denied);
                    }
                else
                {

                    hostparm.ThisHostnetOLD = gContext ->GetSetting("HostNetDevice");
                    QString s = "HostActiveonboot";
                    s+=hostparm.ThisHostnetOLD;
                    hostparm.ThisHostnetActiveOLD = gContext ->GetSetting(s);
                    MSqlQuery query(MSqlQuery::InitCon());
                    query.prepare( "delete from settings where  hostname=:HOSTNAME  and value = 'HOSTNetDevice';  "  );
                    query.bindValue( ":HOSTNAME" ,   gContext->GetHostName()  );
                    query.exec();


                    VerticalConfigurationGroup* networksettings =  new VerticalConfigurationGroup(false,true    ,false,false);
                    networksettings->addChild(HostMyhostname());
                    networksettings->addChild(HostDHCPHostname());
                    networksettings ->setLabel(QObject::tr("Network Settings Page (1/2)"));

                    NetworkSettingsFrame *netsettingsframe = new NetworkSettingsFrame();
                    addChild(networksettings);
                    addChild(netsettingsframe);

                };
            }

            if ( displayshowhostype )
            {
            if (  ((gContext->GetSetting("Hostaccesshostype")) =="0" ))
                {
                    denied ->setLabel(QObject::tr("System type"));
                    addChild(denied);
                }
                else
                {
                    SystemtypeGroup *systemtypegroup = new SystemtypeGroup();
                    vcg->addChild(systemtypegroup);
                    addChild(vcg);
                }
            }

            if ( displayshowmisc )
            {
            if ( ((gContext->GetSetting("Hostaccessmisc")) == "0" ))
                {
                    denied ->setLabel(QObject::tr("NFS Settings"));
                    addChild(denied);
                }
                else
                {
                     MiscMainFrame *miscsettings = new MiscMainFrame();
                    MiscMainFrame2 *miscsettings2 = new MiscMainFrame2();
                     addChild(miscsettings);
                     addChild(miscsettings2);
                }
            }
            if ( displayshowshutdown )
            {
                if ( ((gContext->GetSetting("Hostaccesssleep")) == "0" ))
                {
                    denied ->setLabel(QObject::tr("WOL settings"));
                    addChild(denied);
                }
                else
                {
                    WakeSettings *wakesettings = new WakeSettings();
                    addChild(wakesettings);
                }
            }
            if ( displayshowadvanced )
            {
                if ( ((gContext->GetSetting("Hostaccessadvanced")) == "0" ) )
                {
                    denied ->setLabel(QObject::tr("Advaned Settings"));
                    addChild(denied);
                }
                else
                {
                    AdvancedSettings *advancedsettings = new AdvancedSettings();
                    AdvancedSettings_2 *advancedsettings_2 = new AdvancedSettings_2();

                   // Screensaverhostsettings  *advancedsettings_3 = new Screensaverhostsettings();
//                     advancedsettings_3 ->setLabel(QObject::tr("Advanced settings page 3"));


                    addChild(advancedsettings);
                    addChild(advancedsettings_2);
                 //   addChild(advancedsettings_3);
                }
            }
            if ( displayshowsound )
            {
                if ( ((gContext->GetSetting("Hostaccesssound")) =="0") )
                {
                    denied ->setLabel(QObject::tr("Sound Settings"));
                    addChild(denied);
                }
                else
                {
                    //remove old sound card setting from the db.  This is useful for when the saved setting is no longer valid for this machine.
                    // Later search the list and set the value to the old setting if found in the dropdown.
                    hostparm.OLDHostSoundOSSAnalog = gContext ->GetSetting("HostSoundOssAnalog");
                    hostparm.OLDHostSoundOSSDigital = gContext ->GetSetting("HostSoundOssDigital");
                    hostparm.OLDHostSoundALSAAnalog = gContext ->GetSetting("HostSoundALSAAnalog");
                    hostparm.OLDHostSoundALSADigital= gContext ->GetSetting("HostSoundALSADigital");


                    MSqlQuery query(MSqlQuery::InitCon());
                    query.prepare( "delete from settings where  hostname=:HOSTNAME  and value = 'HOSTSoundOssAnalog';  "  );
                    query.bindValue( ":HOSTNAME" ,   gContext->GetHostName()  );
                    query.exec();
                    query.prepare( "delete from settings where  hostname=:HOSTNAME  and value = 'HOSTSoundALSAAnalog';  "  );
                    query.bindValue( ":HOSTNAME" ,   gContext->GetHostName()  );
                    query.exec();
                    query.prepare( "delete from settings where  hostname=:HOSTNAME  and value = 'HOSTSoundALSADigital';  "  );
                    query.bindValue( ":HOSTNAME" ,   gContext->GetHostName()  );
                    query.exec();
                    query.prepare( "delete from settings where  hostname=:HOSTNAME  and value = 'HOSTSoundOssDigital';  "  );
                    query.bindValue( ":HOSTNAME" ,   gContext->GetHostName()  );
                    query.exec();


                    SoundSettings *soundsettings = new SoundSettings();
                    addChild(soundsettings);
                }
            }
            if ( displayshowadvancedX )
            {
                if ( ((gContext->GetSetting("HostaccessadvancedX")) == "0" ))
                {
                    denied ->setLabel(QObject::tr("AdvancedX Settings"));
                    addChild(denied);
                    }
                    else
                    {
                        AdvancedXSettings *advancedXsettings = new AdvancedXSettings();
                        addChild(advancedXsettings);
                    }
            }
            if ( displayaccesscontrol )
            {
                VerticalConfigurationGroup* accessettings =
                     new VerticalConfigurationGroup(false, true,false,false);;
                ConfigurationGroup *GridAccess =
                    new GridConfigurationGroup(2,false,false,false,false);

                GridAccess->addChild(Hostaccessmisc());
                GridAccess->addChild(Hostaccesssleep());
                GridAccess->addChild(Hostaccessadvanced());
                GridAccess->addChild(HostaccessadvancedX());
                GridAccess->addChild(Hostaccesssound());
                GridAccess->addChild(Hostaccessplugins());
//                GridAccess->addChild(Hostaccessuser());
                GridAccess->addChild(Hostaccesswebuser());

                accessettings->addChild(Hostaccessnetwork());
                accessettings->addChild(new ACCESShostsettings);
                accessettings->addChild(GridAccess);
                accessettings ->setLabel(QObject::tr("Access control"));
                addChild(accessettings);
            }

            if ( displayplugins )
            {
                if ( ((gContext->GetSetting("Hostaccessplugins")) == "0" ))
                {
                    denied ->setLabel(QObject::tr("Plugins"));
                    addChild(denied);
                }
                else
                {
                    ConfigurationGroup *GridShowPlugin = new GridConfigurationGroup(2);
                    GridShowPlugin->addChild(Hostpluginmytharchive());
                    GridShowPlugin->addChild(Hostpluginmythbrowser());
                    GridShowPlugin->addChild(Hostpluginmythcontrols());
                    GridShowPlugin->addChild(Hostpluginmythflix());
                    GridShowPlugin->addChild(Hostpluginmythgallery());
                    GridShowPlugin->addChild(Hostpluginmythmovietime());

                    ConfigurationGroup *GridShowPlugin2 = new GridConfigurationGroup(2);
                    GridShowPlugin2->addChild(Hostpluginmythmusic());
                    GridShowPlugin2->addChild(Hostpluginmythnews());
                    GridShowPlugin2->addChild(Hostpluginmythphone());
                    GridShowPlugin2->addChild(Hostpluginmythsmolt());
                    GridShowPlugin2->addChild(Hostpluginmythweather());
                    GridShowPlugin2->addChild(Hostpluginmythzoneminder());

                    ConfigurationGroup *GridShowPlugin4 = new GridConfigurationGroup(2);
                    GridShowPlugin4->addChild(Hostpluginmythappletrailers());
                    GridShowPlugin4->addChild(Hostpluginmythstream());
                    GridShowPlugin4->addChild(Hostpluginmythvodka());
                    GridShowPlugin4->addChild(HostMiro());
                    GridShowPlugin4->addChild(HostXine());
                    GridShowPlugin4->addChild(Hostwebmin());

                    ConfigurationGroup *GridShowPlugin5 = new GridConfigurationGroup(2);
                    GridShowPlugin5->addChild(Hostfuppes());

		    ConfigurationGroup *GridShowPlugin6 = new VerticalConfigurationGroup(true,true);
                    GridShowPlugin6->addChild(Hostfoldingathome());
                    GridShowPlugin6->addChild(Hostfoldingusername());
                    GridShowPlugin6->addChild(Hostfoldingworksize());

                    ConfigurationGroup *Mythvideoplugin = new HorizontalConfigurationGroup();
                        Mythvideoplugin->addChild(Hostpluginmythvideo());
                        Mythvideoplugin->addChild(Hostpluginmythvideo_dvdcss());


                    ConfigurationGroup *GridShowPlugin3 = new VerticalConfigurationGroup(true,true);
                    GridShowPlugin3->addChild(new MythGamesettings);
                    GridShowPlugin3->addChild(Mythvideoplugin);



                    addChild(GridShowPlugin);
                    addChild(GridShowPlugin2);
                    addChild(GridShowPlugin3);
                    addChild(GridShowPlugin4);
                    addChild(GridShowPlugin5);
                    addChild(GridShowPlugin6);
                }
            }
            if ( displayuser )
            {
                if ( ((gContext->GetSetting("Hostaccessuser")) == "0" ))
                {
                    denied ->setLabel(QObject::tr("User Management"));
                    addChild(denied);
                }
                else
                {
                    UserManagement *usermanagement = new UserManagement();
                    addChild(usermanagement);
                }
            }

            if ( displaywebuser )
            {
                if ( ((gContext->GetSetting("Hostaccesswebuser")) == "0" ))
                {
                    denied ->setLabel(QObject::tr("Web security"));
                    addChild(denied);
                }
                else
                {
                    WebPasswordFrame *webpasswordframe = new WebPasswordFrame();
                    addChild(webpasswordframe);

                }

            }
            if ( displayddns )
            {
                if ( ((gContext->GetSetting("Hostaccessddns")) == "0" ))
                {
                    denied ->setLabel(QObject::tr("DDNS security"));
                    addChild(denied);
                }
                else
                {
                    DDnssettings *ddnsframe = new DDnssettings();
                    addChild(ddnsframe);
                }
            }
            if ( displayinfrared )
            {
//                 if ( ((gContext->GetSetting("Hostaccessddns")) == "0" ))
//                 {
//                     denied ->setLabel(QObject::tr("DDNS security"));
//                     addChild(denied);
//                 }
//                 else
//                 {
                    VERBOSE(VB_IMPORTANT, "LIRC");
                    IRFrame *irframe = new IRFrame();
                    IR_TransmitFrame *transmitframe =  new IR_TransmitFrame();
                    LCDFrame     *lcdframe = new LCDFrame();
                    addChild(irframe);
                    addChild(transmitframe);
                    addChild(lcdframe);
                //}
            }
            if ( displayscreensaver )
            {
//                 if ( ((gContext->GetSetting("Hostaccessddns")) == "0" ))
//                 {
//                     denied ->setLabel(QObject::tr("DDNS security"));
//                     addChild(denied);
//                 }
//                 else
//                 {
                    VERBOSE(VB_IMPORTANT, "screensaver");
                    Screensaverhostsettings  *screensaver = new Screensaverhostsettings();
                    addChild(screensaver);
                //}
            }
        }

};