source: src-qt4/warden-gui/dialogconfig.cpp @ 0cfe72f

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 0cfe72f was 0cfe72f, checked in by Kris Moore <kris@…>, 16 months ago

Add all the changes for related using of split pcbsd-utils libs

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/****************************************************************************
2** ui.h extension file, included from the uic-generated form implementation.
3**
4** If you want to add, delete, or rename functions or slots, use
5** Qt Designer to update this file, preserving your code.
6**
7** You should not define a constructor or destructor in this file.
8** Instead, write your code in functions called init() and destroy().
9** These will automatically be called by the form's constructor and
10** destructor.
11*****************************************************************************/
12#include "dialogconfig.h"
13#include <qsettings.h>
14#include <qfiledialog.h>
15#include "pcbsd-utils.h"
16#include "pcbsd-netif.h"
17
18
19void dialogConfig::programInit()
20{
21    // Load NICS
22    detectDev();
23
24    // Read in the configuration and populate the widget
25    readConfig();
26}
27
28void dialogConfig::detectDev()
29{
30    QString tmp;
31    bool foundDev;
32
33    comboNIC->clear();
34   
35    QStringList ifs = NetworkInterface::getInterfaces();
36    for ( QStringList::Iterator it = ifs.begin(); it != ifs.end(); ++it )
37    {
38       foundDev = false;
39
40       QString dev = *it;
41       if (dev.indexOf("lo") == 0 
42           || dev.indexOf("fwe") == 0
43           || dev.indexOf("fwip") == 0
44           || dev.indexOf("ipfw") == 0
45           || dev.indexOf("plip") == 0
46           || dev.indexOf("pfsync") == 0
47           || dev.indexOf("pflog") == 0
48           || dev.indexOf("usbus") == 0
49           || dev.indexOf("tun") == 0)
50           continue;
51
52        NetworkInterface ifr(dev);
53        if (ifr.isWireless() && dev.indexOf("wlan") != 0 ) 
54           continue;
55
56       comboNIC->addItem(dev);
57   }
58
59}
60
61void dialogConfig::readConfig()
62{
63    QSettings settings("PCBSD");
64   
65    NIC = pcbsd::Utils::getValFromPCConf("/usr/local/etc/warden.conf", "NIC");
66    TMPDIR = pcbsd::Utils::getValFromPCConf("/usr/local/etc/warden.conf", "WTMP");
67    JailDir = pcbsd::Utils::getValFromPCConf("/usr/local/etc/warden.conf", "JDIR");
68   
69    lineJailDir->setText(JailDir);
70    lineTMPDIR->setText(TMPDIR);
71    for ( int i = 0; i < comboNIC->count(); ++i )
72      if ( comboNIC->itemText(i) == NIC )
73         comboNIC->setCurrentIndex(i);
74}
75
76
77void dialogConfig::slotChangeJailDir()
78{
79    QString tmp;
80   
81       tmp = QFileDialog::getExistingDirectory ( this, tr("Select Jail Directory"), JailDir, QFileDialog::ShowDirsOnly );
82       if ( ! tmp.isEmpty() )
83       {
84           lineJailDir->setText(tmp);
85           JailDir = tmp;
86       }
87}
88
89
90void dialogConfig::slotChangeTMPDIR()
91{
92    QString tmp;
93   
94       tmp = QFileDialog::getExistingDirectory ( this, tr("Select Temp Directory"), TMPDIR, QFileDialog::ShowDirsOnly );
95       if ( ! tmp.isEmpty() )
96       {
97           lineTMPDIR->setText(tmp);
98           TMPDIR = tmp;
99       }
100}
101
102
103void dialogConfig::slotSave()
104{
105   
106    pcbsd::Utils::setValPCConf("/usr/local/etc/warden.conf", "NIC", comboNIC->currentText());
107    pcbsd::Utils::setValPCConf("/usr/local/etc/warden.conf", "WTMP", lineTMPDIR->text());
108    pcbsd::Utils::setValPCConf("/usr/local/etc/warden.conf", "JDIR", lineJailDir->text());
109   
110    emit saved();
111    close();
112}
113
114
115void dialogConfig::slotCancel()
116{
117    close();
118}
Note: See TracBrowser for help on using the repository browser.