aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/remote_settings_dialog.cpp
blob: 4f7fddf6ed6d089bfc19e6bc005a21190a7008d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* remote_settings_dialog.cpp
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

// XXX This shouldn't exist. These controls should be in ManageInterfacesDialog instead.

#include "config.h"
#ifdef HAVE_PCAP_REMOTE
#include "remote_settings_dialog.h"
#include <ui_remote_settings_dialog.h>

RemoteSettingsDialog::RemoteSettingsDialog(QWidget *parent, interface_t *iface) :
    QDialog(parent),
    ui(new Ui::RemoteSettingsDialog)
{
    ui->setupUi(this);
    mydevice.name = g_strdup(iface->name);
    ui->rpcapBox->setCheckState(iface->remote_opts.remote_host_opts.nocap_rpcap?Qt::Checked:Qt::Unchecked);
    ui->udpBox->setCheckState(iface->remote_opts.remote_host_opts.datatx_udp?Qt::Checked:Qt::Unchecked);
#ifdef HAVE_PCAP_SETSAMPLING
    switch (iface->remote_opts.sampling_method)
    {
    case CAPTURE_SAMP_NONE:
        ui->sampleNone->setChecked(true);
        break;
    case CAPTURE_SAMP_BY_COUNT:
        ui->samplePkt->setChecked(true);
        ui->spinPkt->setValue(iface->remote_opts.sampling_param);
        break;
    case CAPTURE_SAMP_BY_TIMER:
        ui->sampleTime->setChecked(true);
        ui->spinTime->setValue(iface->remote_opts.sampling_param);
        break;
    }
#else
    ui->sampleLabel->setVisible(false);
    ui->sampleNone->setVisible(false);
    ui->samplePkt->setVisible(false);
    ui->sampleTime->setVisible(false);
    ui->spinPkt->setVisible(false);
    ui->spinTime->setVisible(false);
    ui->pktLabel->setVisible(false);
    ui->timeLabel->setVisible(false);
    resize(width(), height() - ui->sampleLabel->height() - 3 * ui->sampleNone->height());
#endif
    connect(this, SIGNAL(remoteSettingsChanged(interface_t *)), parent, SIGNAL(remoteSettingsChanged(interface_t *)));
}

RemoteSettingsDialog::~RemoteSettingsDialog()
{
    delete ui;
}

void RemoteSettingsDialog::on_buttonBox_accepted()
{
    mydevice.remote_opts.remote_host_opts.nocap_rpcap = (ui->rpcapBox->checkState()==Qt::Checked)?true:false;
    mydevice.remote_opts.remote_host_opts.datatx_udp = (ui->udpBox->checkState()==Qt::Checked)?true:false;
#ifdef HAVE_PCAP_SETSAMPLING
    if (ui->sampleNone->isChecked()) {
        mydevice.remote_opts.sampling_method = CAPTURE_SAMP_NONE;
        mydevice.remote_opts.sampling_param = 0;
    } else if (ui->samplePkt->isChecked()) {
        mydevice.remote_opts.sampling_method = CAPTURE_SAMP_BY_COUNT;
        mydevice.remote_opts.sampling_param = ui->spinPkt->value();
    } else {
        mydevice.remote_opts.sampling_method = CAPTURE_SAMP_BY_TIMER;
        mydevice.remote_opts.sampling_param = ui->spinTime->value();
    }
#endif
    emit remoteSettingsChanged(&mydevice);
}
#endif

/*
 * Editor modelines
 *
 * Local Variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * ex: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */