void ManageInterfacesDialog::localAccepted()
{

    if (global_capture_opts.all_ifaces->len > 0) {
        QStringList hide_list;
        QStringList comment_list;
        QTreeWidgetItemIterator it(ui->localList);
        while (*it) {
            if ((*it)->checkState(col_l_show_) != Qt::Checked) {
                hide_list << (*it)->text(col_l_local_name_);
            }

            if (!(*it)->text(col_l_local_name_).isEmpty()) {
                comment_list << QString("%1(%2)").arg((*it)->text(col_l_local_name_)).arg((*it)->text(col_l_comment_));
            }

            saveLocalHideChanges(*it);
            saveLocalCommentChanges(*it);
            ++it;
        }
        /* write new "hidden" string to preferences */
        g_free(prefs.capture_devices_hide);
        gchar *new_hide = qstring_strdup(hide_list.join(","));
        prefs.capture_devices_hide = new_hide;
        hide_interface(g_strdup(new_hide));

        /* write new description string to preferences */
        if (prefs.capture_devices_descr)
            g_free(prefs.capture_devices_descr);
        prefs.capture_devices_descr = qstring_strdup(comment_list.join(","));
    }
}
void InterfaceTreeCacheModel::saveNewDevices()
{
    QList<interface_t *>::const_iterator it = newDevices.constBegin();
    /* idx is used for iterating only over the indices of the new devices. As all new
     * devices are stored with an index higher then sourceModel->rowCount(), we start
     * only with those storage indices.
     * it is just the iterator over the new devices. A new device must not necessarily
     * have storage, which will lead to that device not being stored in global_capture_opts */
    for (int idx = sourceModel->rowCount(); it != newDevices.constEnd(); ++it, idx++)
    {
        interface_t * device = (interface_t *)(*it);
        bool useDevice = false;

        QMap<InterfaceTreeColumns, QVariant> * dataField = storage->value(idx, 0);
        /* When devices are being added, they are added using generic values. So only devices
         * whose data have been changed should be used from here on out. */
        if ( dataField != 0 )
        {
            if ( device->if_info.type != IF_PIPE )
            {
                continue;
            }

            if ( device->if_info.type == IF_PIPE )
            {
                QVariant saveValue = dataField->value(IFTREE_COL_PIPE_PATH);
                if ( saveValue.isValid() )
                {
                    g_free(device->if_info.name);
                    device->if_info.name = qstring_strdup(saveValue.toString());

                    g_free(device->name);
                    device->name = qstring_strdup(saveValue.toString());

                    g_free(device->display_name);
                    device->display_name = qstring_strdup(saveValue.toString());
                    useDevice = true;
                }
            }

            if ( useDevice )
                g_array_append_val(global_capture_opts.all_ifaces, *device);

        }

        /* All entries of this new devices have been considered */
        storage->remove(idx);
        delete dataField;
    }

    qDeleteAll(newDevices);
    newDevices.clear();
}
void ColumnPreferencesFrame::unstash()
{
    GList *new_col_list = NULL;
    bool changed = false;

    QTreeWidgetItemIterator it(ui->columnTreeWidget);
    while (*it) {
        fmt_data *cfmt = g_new0(fmt_data, 1);

        cfmt->title = qstring_strdup((*it)->text(title_col_));
        cfmt->fmt = (*it)->data(type_col_, Qt::UserRole).value<int>();
        cfmt->visible = (*it)->checkState(visible_col_) == Qt::Checked ? TRUE : FALSE;
        cfmt->resolved = TRUE;

        if (cfmt->fmt == COL_CUSTOM) {
            bool ok;
            int occurrence = (*it)->text(custom_occurrence_col_).toInt(&ok);
            cfmt->custom_field = qstring_strdup((*it)->text(custom_field_col_));
            cfmt->custom_occurrence = ok ? occurrence : 0;
        }

        if (prefs.col_list == NULL) {
            changed = true;
        } else {
            fmt_data *old_cfmt = (fmt_data *) prefs.col_list->data;
            if (!old_cfmt ||
                    g_strcmp0(old_cfmt->title, cfmt->title) != 0 ||
                    old_cfmt->fmt != cfmt->fmt ||
                    old_cfmt->visible != cfmt->visible ||
                    (old_cfmt->fmt == COL_CUSTOM && (
                         g_strcmp0(old_cfmt->custom_field, cfmt->custom_field) != 0 ||
                         old_cfmt->custom_occurrence != cfmt->custom_occurrence))) {
                changed = true;
            }
            column_prefs_remove_link(prefs.col_list);
        }

        new_col_list = g_list_append(new_col_list, cfmt);
        ++it;
    }

    while (prefs.col_list) {
        changed = true;
        column_prefs_remove_link(prefs.col_list);
    }
    prefs.col_list = new_col_list;

    if (changed) {
        wsApp->emitAppSignal(WiresharkApplication::ColumnsChanged);
    }
}
Ejemplo n.º 4
0
void CaptureFilterEdit::setFilterSyntaxState(QString filter, bool valid, QString err_msg)
{
    if (filter.compare(text()) == 0) { // The user hasn't changed the filter
        if (valid) {
            setSyntaxState(text().isEmpty() ? Empty : Valid);
        } else {
            setSyntaxState(Invalid);
            emit pushFilterSyntaxStatus(err_msg);
        }
    }

#ifdef HAVE_LIBPCAP
    if (syntaxState() != Invalid) {
        if (bookmark_button_) {
            bookmark_button_->setEnabled(true);
        }
        if (apply_button_) {
            apply_button_->setEnabled(true);
        }
        valid = true;
        g_free(global_capture_opts.default_options.cfilter);
        if (filter.isEmpty()) {
            global_capture_opts.default_options.cfilter = NULL;
        } else {
            global_capture_opts.default_options.cfilter = qstring_strdup(filter);
        }

        if (global_capture_opts.num_selected > 0) {
            interface_t device;

            for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) {
                device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
                if (!device.selected) {
                    continue;
                }
//                if (device.active_dlt == -1) {
//                    simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The link type of interface %s was not specified.", device.name);
//                    continue;  /* Programming error: somehow managed to select an "unsupported" entry */
//                }
                g_array_remove_index(global_capture_opts.all_ifaces, i);
                device.cfilter = qstring_strdup(filter);
                g_array_insert_val(global_capture_opts.all_ifaces, i, device);
//                update_filter_string(device.name, filter_text);
            }
        }
    }
#endif // HAVE_LIBPCAP

    emit captureFilterSyntaxChanged(valid);
}
void FilterExpressionsPreferencesFrame::unstash()
{
    struct filter_expression *cur_fe = *pfilter_expression_head, *new_fe_head = NULL, *new_fe = NULL;
    bool changed = false;

    QTreeWidgetItemIterator it(ui->expressionTreeWidget);
    while (*it) {
        struct filter_expression *fe = g_new0(struct filter_expression, 1);

        if (!new_fe_head) {
            new_fe_head = fe;
        } else {
            new_fe->next = fe;
        }
        new_fe = fe;

        new_fe->enabled = (*it)->checkState(enabled_col_) == Qt::Checked ? TRUE : FALSE;
        new_fe->label = qstring_strdup((*it)->text(label_col_));
        new_fe->expression = qstring_strdup((*it)->text(expression_col_));

        if (cur_fe == NULL) {
            changed = true;
        } else {
            if (cur_fe->enabled != new_fe->enabled ||
                    g_strcmp0(cur_fe->label, new_fe->label) != 0 ||
                    g_strcmp0(cur_fe->expression, new_fe->expression) != 0) {
                changed = true;
            }
            cur_fe = cur_fe->next;
        }
        ++it;
    }

    if (cur_fe) changed = true;

    cur_fe = new_fe_head;
    if (changed) {
        cur_fe = *pfilter_expression_head;
        *pfilter_expression_head = new_fe_head;
        wsApp->emitAppSignal(WiresharkApplication::FilterExpressionsChanged);
    }

    while (cur_fe) {
        struct filter_expression *fe = cur_fe;
        cur_fe = fe->next;
        g_free(fe->label);
        g_free(fe->expression);
        g_free(fe);
    }
}
Ejemplo n.º 6
0
void ManageInterfacesDialog::saveLocalCommentChanges(QTreeWidgetItem* item)
{
    guint i;
    interface_t device;

    if (!item) {
        return;
    }

    QString name = item->text(col_l_local_name_);
    QString comment = item->text(col_l_comment_);
    /* See if this is the currently selected capturing device */

    for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
        device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
        if (name.compare(device.name)) {
            continue;
        }

        g_free(device.display_name);
        // XXX The GTK+ UI uses the raw device name instead of the friendly name.
        // This seems to make more sense.
        gchar *if_string = device.friendly_name ? device.friendly_name : device.name;
        if (comment.isEmpty()) {
            device.display_name = g_strdup(if_string);
        } else {
            device.display_name = qstring_strdup(QString("%1: %2").arg(comment).arg(if_string));
        }
        global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
        g_array_insert_val(global_capture_opts.all_ifaces, i, device);
    }
}
void MainWindowPreferencesFrame::on_foStyleSpecifiedLineEdit_textEdited(const QString &new_dir)
{
    g_free(pref_fileopen_dir_->stashed_val.string);
    pref_fileopen_dir_->stashed_val.string = qstring_strdup(new_dir);
    pref_fileopen_style_->stashed_val.enumval = FO_STYLE_SPECIFIED;
    updateWidgets();
}
void MainWindowPreferencesFrame::on_foStyleSpecifiedPushButton_clicked()
{
    QString specified_dir = QFileDialog::getExistingDirectory(this, tr("Open Files In"));

    if (specified_dir.isEmpty()) return;

    ui->foStyleSpecifiedLineEdit->setText(specified_dir);
    g_free(pref_fileopen_dir_->stashed_val.string);
    pref_fileopen_dir_->stashed_val.string = qstring_strdup(specified_dir);
    pref_fileopen_style_->stashed_val.enumval = FO_STYLE_SPECIFIED;
    updateWidgets();
}
Ejemplo n.º 9
0
void ProfileDialog::editingFinished()
{
    QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem();

    if (item) {
        profile_def *profile = (profile_def *) item->data(0, Qt::UserRole).value<GList *>()->data;
        if (item->text(0).compare(profile->name) != 0) {
            g_free(profile->name);
            profile->name = qstring_strdup(item->text(0));
        }
    }
    updateWidgets();
}
Ejemplo n.º 10
0
void ProfileDialog::editingFinished()
{
    QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem();

    if (item) {
        profile_def *profile = (profile_def *) VariantPointer<GList>::asPtr(item->data(0, Qt::UserRole))->data;
        if (item->text(0).compare(profile->name) != 0) {
            g_free(profile->name);
            profile->name = qstring_strdup(item->text(0));
            if (profile->status == PROF_STAT_EXISTS) {
                profile->status = PROF_STAT_CHANGED;
            }
        }
    }
    updateWidgets();
}
void RemoteCaptureDialog::apply_remote()
{
    int err;
    gchar *err_str;
    remote_options global_remote_opts;

    QString host = ui->hostCombo->currentText();
    global_remote_opts.src_type = CAPTURE_IFREMOTE;
    global_remote_opts.remote_host_opts.remote_host = qstring_strdup(host);
    QString port = ui->portText->text();
    global_remote_opts.remote_host_opts.remote_port = qstring_strdup(port);
    if (ui->pwAuth->isChecked()) {
        global_remote_opts.remote_host_opts.auth_type = CAPTURE_AUTH_PWD;
    } else {
        global_remote_opts.remote_host_opts.auth_type = CAPTURE_AUTH_NULL;
    }
    QString user = ui->userText->text();
    global_remote_opts.remote_host_opts.auth_username = qstring_strdup(user);
    QString pw = ui->pwText->text();
    global_remote_opts.remote_host_opts.auth_password = qstring_strdup(pw);
    GList *rlist = get_remote_interface_list(global_remote_opts.remote_host_opts.remote_host,
                                              global_remote_opts.remote_host_opts.remote_port,
                                              global_remote_opts.remote_host_opts.auth_type,
                                              global_remote_opts.remote_host_opts.auth_username,
                                              global_remote_opts.remote_host_opts.auth_password,
                                              &err, &err_str);
    if (rlist == NULL &&
        (err == CANT_GET_INTERFACE_LIST || err == DONT_HAVE_PCAP)) {
        QMessageBox::warning(this, tr("Error"),
                             (err == CANT_GET_INTERFACE_LIST?tr("No remote interfaces found."):tr("PCAP not found")));
        return;
    }
    if (ui->hostCombo->count() == 0) {
        ui->hostCombo->addItem("");
        ui->hostCombo->addItem(host);
        ui->hostCombo->insertSeparator(2);
        ui->hostCombo->addItem(QString(tr("Clear list")));
    } else {
        ui->hostCombo->insertItem(0, host);
    }
    struct remote_host *rh = recent_get_remote_host(host.toUtf8().constData());
    if (!rh) {
        rh = (struct remote_host *)g_malloc (sizeof (*rh));
        rh->r_host = qstring_strdup(host);
        rh->remote_port = qstring_strdup(port);
        rh->auth_type = global_remote_opts.remote_host_opts.auth_type;
        rh->auth_password = g_strdup("");
        rh->auth_username = g_strdup("");
        recent_add_remote_host(global_remote_opts.remote_host_opts.remote_host, rh);
    }
    emit remoteAdded(rlist, &global_remote_opts);
}
Ejemplo n.º 12
0
void WiresharkApplication::setMonospaceFont(const char *font_string) {

    if (font_string && strlen(font_string) > 0) {
        mono_font_.fromString(font_string);
//        mono_bold_font_ = QFont(mono_regular_font_);
//        mono_bold_font_.setBold(true);
        return;
    }

    // http://en.wikipedia.org/wiki/Category:Monospaced_typefaces
    const char *win_default_font = "Consolas";
    const char *win_alt_font = "Lucida Console";
    const char *osx_default_font = "Menlo";
    const char *osx_alt_font = "Monaco";
    const char *x11_default_font = "Liberation Mono";
    const QStringList x11_alt_fonts = QStringList() << "DejaVu Sans Mono" << "Bitstream Vera Sans Mono";
    const QStringList fallback_fonts = QStringList() << "Lucida Sans Typewriter" << "Inconsolata" << "Droid Sans Mono" << "Andale Mono" << "Courier New" << "monospace";
    QStringList substitutes;
    int font_size_adjust = 0;

    // Try to pick the latest, shiniest fixed-width font for our OS.
#if defined(Q_OS_WIN)
    const char *default_font = win_default_font;
    substitutes << win_alt_font << osx_default_font << osx_alt_font << x11_default_font << x11_alt_fonts << fallback_fonts;
    font_size_adjust = 2;
#elif defined(Q_OS_MAC)
    const char *default_font = osx_default_font;
    substitutes << osx_alt_font << win_default_font << win_alt_font << x11_default_font << x11_alt_fonts << fallback_fonts;
#else
    const char *default_font = x11_default_font;
    substitutes << x11_alt_fonts << win_default_font << win_alt_font << osx_default_font << osx_alt_font << fallback_fonts;
#endif

    mono_font_.setFamily(default_font);
    mono_font_.insertSubstitutions(default_font, substitutes);
    mono_font_.setPointSize(wsApp->font().pointSize() + font_size_adjust);
    mono_font_.setBold(false);

//    mono_bold_font_ = QFont(mono_font_);
//    mono_bold_font_.setBold(true);

    g_free(prefs.gui_qt_font_name);
    prefs.gui_qt_font_name = qstring_strdup(mono_font_.toString());
}
void PreferenceEditorFrame::on_okButton_clicked()
{
    bool apply = false;
    switch(pref_->type) {
    case PREF_UINT:
        if (pref_->stashed_val.uint != new_uint_) {
            pref_->stashed_val.uint = new_uint_;
            apply = true;
        }
        break;
    case PREF_STRING:
        if (new_str_.compare(pref_->stashed_val.string) != 0) {
            g_free(pref_->stashed_val.string);
            pref_->stashed_val.string = qstring_strdup(new_str_);
            apply = true;
        }
        break;
    case PREF_RANGE:
        if (!ranges_are_equal(pref_->stashed_val.range, new_range_)) {
            g_free(pref_->stashed_val.range);
            pref_->stashed_val.range = range_copy(new_range_);
            apply = true;
        }
        break;
    default:
        break;
    }

    if (apply && module_) {
        pref_unstash(pref_, &module_->prefs_changed);
        prefs_apply(module_);
        if (!prefs.gui_use_pref_save) {
            prefs_main_write();
        }
    }
    on_cancelButton_clicked();
    // Emit signals once UI is hidden
    if (apply) {
        wsApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged);
        wsApp->emitAppSignal(WiresharkApplication::PreferencesChanged);
    }
}
void InterfaceTreeCacheModel::save()
{
    if ( storage->count() == 0 )
        return;

    QMap<char**, QStringList> prefStorage;


    /* Storing new devices first including their changed values */
    saveNewDevices();


    for(unsigned int idx = 0; idx < global_capture_opts.all_ifaces->len; idx++)
    {
        interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, idx);

        if (! device.name )
            continue;

        /* Try to load a saved value row for this index */
        QMap<InterfaceTreeColumns, QVariant> * dataField = storage->value(idx, 0);

        /* Handle the storing of values for this device here */
        if ( dataField )
        {
            QMap<InterfaceTreeColumns, QVariant>::const_iterator it = dataField->constBegin();
            while ( it != dataField->constEnd() )
            {
                InterfaceTreeColumns col = it.key();
                QVariant saveValue = it.value();

                /* Setting the field values for each individual saved value cannot be generic, as the
                 * struct cannot be accessed in a generic way. Therefore below, each individually changed
                 * value has to be handled separately. Comments are stored only in the preference file
                 * and applied to the data name during loading. Therefore comments are not handled here */

                if ( col == IFTREE_COL_HIDDEN )
                {
                    device.hidden = saveValue.toBool();
                }
#ifdef HAVE_EXTCAP
                else if ( device.if_info.type == IF_EXTCAP )
                {
                    /* extcap interfaces do not have the following columns.
                     * ATTENTION: all generic columns must be added, BEFORE this
                     * if-clause, or they will be ignored for extcap interfaces */
                }
#endif
                else if ( col == IFTREE_COL_PROMISCUOUSMODE )
                {
                    device.pmode = saveValue.toBool();
                }
#ifdef HAVE_PCAP_CREATE
                else if ( col == IFTREE_COL_MONITOR_MODE )
                {
                    device.monitor_mode_enabled = saveValue.toBool();
                }
#endif
                else if ( col == IFTREE_COL_SNAPLEN )
                {
                    int iVal = saveValue.toInt();
                    if ( iVal != WTAP_MAX_PACKET_SIZE )
                    {
                        device.has_snaplen = true;
                        device.snaplen = iVal;
                    }
                    else
                    {
                        device.has_snaplen = false;
                        device.snaplen = WTAP_MAX_PACKET_SIZE;
                    }
                }
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
                else if ( col == IFTREE_COL_BUFFERLEN )
                {
                    device.buffer = saveValue.toInt();
                }
#endif

                global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, idx);
                g_array_insert_val(global_capture_opts.all_ifaces, idx, device);

                ++it;
            }
        }

        QVariant content = getColumnContent(idx, IFTREE_COL_HIDDEN, Qt::CheckStateRole);
        if ( content.isValid() && static_cast<Qt::CheckState>(content.toInt()) == Qt::Unchecked )
                prefStorage[&prefs.capture_devices_hide] << QString(device.name);

        content = getColumnContent(idx, IFTREE_COL_INTERFACE_COMMENT);
        if ( content.isValid() && content.toString().size() > 0 )
            prefStorage[&prefs.capture_devices_descr] << QString("%1(%2)").arg(device.name).arg(content.toString());

        bool allowExtendedColumns = true;
#ifdef HAVE_EXTCAP
        if ( device.if_info.type == IF_EXTCAP )
            allowExtendedColumns = false;
#endif
        if ( allowExtendedColumns )
        {
            content = getColumnContent(idx, IFTREE_COL_PROMISCUOUSMODE, Qt::CheckStateRole);
            if ( content.isValid() )
            {
                bool value = static_cast<Qt::CheckState>(content.toInt()) == Qt::Checked;
                prefStorage[&prefs.capture_devices_pmode]  << QString("%1(%2)").arg(device.name).arg(value ? 1 : 0);
            }

#ifdef HAVE_PCAP_CREATE
            content = getColumnContent(idx, IFTREE_COL_MONITOR_MODE, Qt::CheckStateRole);
            if ( content.isValid() && static_cast<Qt::CheckState>(content.toInt()) == Qt::Checked )
                    prefStorage[&prefs.capture_devices_monitor_mode] << QString(device.name);
#endif

            content = getColumnContent(idx, IFTREE_COL_SNAPLEN);
            if ( content.isValid() )
            {
                int value = content.toInt();
                prefStorage[&prefs.capture_devices_snaplen]  <<
                        QString("%1:%2(%3)").arg(device.name).
                        arg(device.has_snaplen ? 1 : 0).
                        arg(device.has_snaplen ? value : WTAP_MAX_PACKET_SIZE);
            }

#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
            content = getColumnContent(idx, IFTREE_COL_BUFFERLEN);
            if ( content.isValid() )
            {
                int value = content.toInt();
                if ( value != -1 )
                {
                    prefStorage[&prefs.capture_devices_buffersize]  <<
                            QString("%1(%2)").arg(device.name).
                            arg(value);
                }
            }
#endif
        }
    }

    QMap<char**, QStringList>::const_iterator it = prefStorage.constBegin();
    while ( it != prefStorage.constEnd() )
    {
        char ** key = it.key();

        g_free(*key);
        *key = qstring_strdup(it.value().join(","));

        ++it;
    }

    wsApp->emitAppSignal(WiresharkApplication::LocalInterfacesChanged);
}
Ejemplo n.º 15
0
const char *FunnelTextDialog::getText()
{
    return qstring_strdup(ui->textEdit->toPlainText());
}
void ManageInterfacesDialog::pipeAccepted()
{
    interface_t device;

    // First clear the current pipes
    for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) {
        device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
        /* Continue if capture device is hidden or not a pipe */
        if (device.hidden || device.type != IF_PIPE) {
            continue;
        }
        global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
    }

    // Next rebuild a fresh list
    QTreeWidgetItemIterator it(ui->pipeList);
    while (*it) {
        QString pipe_name = (*it)->text(col_p_pipe_);
        if (pipe_name.isEmpty() || pipe_name == new_pipe_default_) {
            ++it;
            continue;
        }

        for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) {
            // Instead of just deleting the device we might want to add a hint label
            // and let the user know what's going to happen.
            device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
            if (pipe_name.compare(device.name) == 0) { // Duplicate
                ++it;
                continue;
            }
        }

        device.name         = qstring_strdup(pipe_name);
        device.display_name = g_strdup(device.name);
        device.hidden       = FALSE;
        device.selected     = TRUE;
        device.type         = IF_PIPE;
        device.pmode        = global_capture_opts.default_options.promisc_mode;
        device.has_snaplen  = global_capture_opts.default_options.has_snaplen;
        device.snaplen      = global_capture_opts.default_options.snaplen;
        device.cfilter      = g_strdup(global_capture_opts.default_options.cfilter);
        device.addresses    = NULL;
        device.no_addresses = 0;
        device.last_packets = 0;
        device.links        = NULL;
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
        device.buffer       = DEFAULT_CAPTURE_BUFFER_SIZE;
#endif
        device.active_dlt = -1;
        device.locked = FALSE;
        device.if_info.name = g_strdup(device.name);
        device.if_info.friendly_name = NULL;
        device.if_info.vendor_description = NULL;
        device.if_info.addrs = NULL;
        device.if_info.loopback = FALSE;
        device.if_info.type = IF_PIPE;
#ifdef HAVE_EXTCAP
        device.if_info.extcap = NULL;
        device.external_cap_args_settings = NULL;
#endif
#if defined(HAVE_PCAP_CREATE)
        device.monitor_mode_enabled = FALSE;
        device.monitor_mode_supported = FALSE;
#endif
        global_capture_opts.num_selected++;
        g_array_append_val(global_capture_opts.all_ifaces, device);
        ++it;
    }
}
int ExportDissectionDialog::exec()
{
#if !defined(Q_OS_WIN)
    int retval;

    if (!cap_file_) return QDialog::Rejected;

    retval = QFileDialog::exec();

    if (retval ==  QDialog::Accepted && selectedFiles().length() > 0) {
        cf_print_status_t status;
        QString file_name = selectedFiles()[0];

        /* Fill in our print (and export) args */

        print_args_.file                = qstring_strdup(file_name);
        print_args_.format              = PR_FMT_TEXT;
        print_args_.to_file             = TRUE;
        print_args_.cmd                 = NULL;
        print_args_.print_summary       = TRUE;
        print_args_.print_dissections   = print_dissections_as_displayed;
        print_args_.print_hex           = FALSE;
        print_args_.print_formfeed      = FALSE;

        switch (export_type_) {
        case export_type_text:      /* Text */
            print_args_.print_summary = packet_format_group_box_.summaryEnabled();
            print_args_.print_dissections = print_dissections_none;
            if (packet_format_group_box_.detailsEnabled()) {
                if (packet_format_group_box_.allCollapsedEnabled())
                    print_args_.print_dissections = print_dissections_collapsed;
                else if (packet_format_group_box_.asDisplayedEnabled())
                    print_args_.print_dissections = print_dissections_as_displayed;
                else if (packet_format_group_box_.allExpandedEnabled())
                    print_args_.print_dissections = print_dissections_expanded;
            }
            print_args_.print_hex = packet_format_group_box_.bytesEnabled();
            print_args_.stream = print_stream_text_new(TRUE, print_args_.file);
            if (print_args_.stream == NULL) {
                open_failure_alert_box(print_args_.file, errno, TRUE);
                return QDialog::Rejected;
            }
            status = cf_print_packets(cap_file_, &print_args_, TRUE);
            break;
        case export_type_csv:       /* CSV */
            status = cf_write_csv_packets(cap_file_, &print_args_);
            break;
        case export_type_carrays:   /* C Arrays */
            status = cf_write_carrays_packets(cap_file_, &print_args_);
            break;
        case export_type_psml:      /* PSML */
            status = cf_write_psml_packets(cap_file_, &print_args_);
            break;
        case export_type_pdml:      /* PDML */
            status = cf_write_pdml_packets(cap_file_, &print_args_);
            break;
        case export_type_json:      /* JSON */
            status = cf_write_json_packets(cap_file_, &print_args_);
            break;
        default:
            return QDialog::Rejected;
        }

        switch (status) {
            case CF_PRINT_OK:
                break;
            case CF_PRINT_OPEN_ERROR:
                open_failure_alert_box(print_args_.file, errno, TRUE);
                break;
            case CF_PRINT_WRITE_ERROR:
                write_failure_alert_box(print_args_.file, errno);
                break;
        }

        if (selectedFiles().length() > 0) {
            gchar *dirname;
            /* Save the directory name for future file dialogs. */
            dirname = get_dirname(print_args_.file);  /* Overwrites file_name data */
            set_last_open_dir(dirname);
        }
    }

    return retval;
#else // Q_OS_WIN
    win32_export_file((HWND)parentWidget()->effectiveWinId(), cap_file_, export_type_);
    return QDialog::Accepted;
#endif // Q_OS_WIN
}