예제 #1
0
    // ipv6 mode
    connect(ui->checkBox_ip6, SIGNAL(stateChanged(int)), this, SLOT(ip6Enable(int)));
    connect(ui->comboBox_ip6, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeIp6Mode(QString)));
    // dhcp client
    connect(ui->comboBox_dhcp, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDhcpClient(QString)));
    // buttons
    connect(ui->pushButton_ipAddress, SIGNAL(clicked(bool)), this, SLOT(addIp()));
    connect(ui->lineEdit_ipAddress, SIGNAL(returnPressed()), this, SLOT(addIp()));
    connect(ui->pushButton_ipRoutes, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes()));
    connect(ui->pushButton_ipAddress6, SIGNAL(clicked(bool)), this, SLOT(addIp6()));
    connect(ui->lineEdit_ipAddress6, SIGNAL(returnPressed()), this, SLOT(addIp6()));
    connect(ui->pushButton_ipRoutes6, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes6()));
    connect(ui->pushButton_custom, SIGNAL(clicked(bool)), this, SLOT(addCustom()));
    connect(ui->lineEdit_custom, SIGNAL(returnPressed()), this, SLOT(addCustom()));
    connect(ui->pushButton_dns, SIGNAL(clicked(bool)), this, SLOT(addDns()));
    connect(ui->lineEdit_dns, SIGNAL(returnPressed()), this, SLOT(addDns()));
    connect(ui->pushButton_dnsOptions, SIGNAL(clicked(bool)), this, SLOT(addDnsOpt()));
    connect(ui->lineEdit_dnsOptions, SIGNAL(returnPressed()), this, SLOT(addDnsOpt()));
}


void IpWidget::createFilter()
{
    // ipv4
    ui->lineEdit_ipAddress->setValidator(IpRegExp::ipv4CidrValidator());
    ui->lineEdit_gateway->setValidator(IpRegExp::ipv4Validator());
    ui->lineEdit_ipRoutes->setValidator(IpRegExp::ipv4CidrValidator());
    ui->lineEdit_ipRoutes2->setValidator(IpRegExp::ipv4Validator());

    // ipv6
    ui->lineEdit_ipAddress6->setValidator(IpRegExp::ipv6CidrValidator());
예제 #2
0
DeviceSettings::DeviceSettings( QWidget *parent, QString dev, bool wifi )
    : DeviceSettingsDlg( parent ),
      _dev( dev ),
      _wifi( wifi )
{
    // ip validator
    rx = new QRegExp( "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}" );
    validator = new QRegExpValidator( *rx, this );

    ipaddr->setValidator( validator );
    defaultgw->setValidator( validator );
    broadcast->setValidator( validator );
    netmask->setValidator( validator );

    // if ipaddr is changed we should recalculate broadcast and netmask
    // for now we just clear it.
    connect( ipaddr, SIGNAL( textChanged( const QString& ) ),
             this, SLOT( slotIPChanged() ) );

    // fill automatic types, for now only DHCP is supported
    automaticCombo->insertItem( "DHCP" );

    // fill dnsListBox
    dnsListBox->clear();
    QStringList dnsList = getDnsList();
    QStringList::ConstIterator end = dnsList.end();
    for ( QStringList::ConstIterator it = dnsList.begin();
          it != end; ++it ) {
        dnsListBox->insertItem( *it );
    }

    connect( addDnsButton, SIGNAL( clicked() ),
             this, SLOT( addDns() ) );
    connect( removeDnsButton, SIGNAL( clicked() ),
             this, SLOT( removeDns() ) );


    // get device information from kernel.
    struct sockaddr_in *sin;
    struct ifreq ifr;
    int skfd = sockets_open();
    strcpy( ifr.ifr_name, _dev.ascii() );
    // IP
    ioctl( skfd, SIOCGIFADDR, &ifr );
    sin = (struct sockaddr_in *)&ifr.ifr_addr;
    ipaddr->setText( inet_ntoa( sin->sin_addr ) );
    // Broadcast
    ioctl( skfd, SIOCGIFBRDADDR, &ifr );
    sin = (struct sockaddr_in *)&ifr.ifr_addr;
    broadcast->setText( inet_ntoa( sin->sin_addr ) );
    // Netmask
    ioctl( skfd, SIOCGIFNETMASK, &ifr );
    sin = (struct sockaddr_in *)&ifr.ifr_addr;
    netmask->setText( inet_ntoa( sin->sin_addr ) );


    connect( automaticButton, SIGNAL( toggled( bool ) ),
             this, SLOT( automaticToggled( bool ) ) );
    connect( manualButton, SIGNAL( toggled( bool ) ),
             this, SLOT( manualToggled( bool ) ) );

    connect( applyButton, SIGNAL( clicked() ),
             this, SLOT( slotApply() ) );
    connect( cancelButton, SIGNAL( clicked() ),
             this, SLOT( slotCancel() ) );

    KConfig *config = new KConfig( "tasmanetrc" );
    config->setGroup( _dev );
    QString _connType = config->readEntry( "ConnectionType", "Automatic" );
    defaultgw->setText( config->readEntry( "DefaultGateway", "" ) );
    if ( _connType == "Automatic" ) {
        automaticButton->setChecked( true );
    }
    else if ( _connType == "Manual" ) {
        manualButton->setChecked( true );
    }

    delete config;
}