Show the object export dialog in accordance with the Qt

documentation. Remove our tap listener and clean up after ourselves.

svn path=/trunk/; revision=45648
This commit is contained in:
Gerald Combs 2012-10-18 21:51:38 +00:00
parent 576b24c96e
commit 97fa2f2a5f
3 changed files with 44 additions and 39 deletions

View File

@ -56,7 +56,7 @@ static void
eo_reset(void *tapdata)
{
export_object_list_t *object_list = (export_object_list_t *) tapdata;
if (object_list) object_list->eod->resetObjects();
if (object_list && object_list->eod) object_list->eod->resetObjects();
}
} // extern "C"
@ -113,42 +113,17 @@ ExportObjectDialog::ExportObjectDialog(QWidget *parent, capture_file *cf, Object
connect(wsApp, SIGNAL(captureFileClosing(const capture_file*)),
this, SLOT(captureFileClosing(const capture_file*)));
show();
raise();
activateWindow();
}
ExportObjectDialog::~ExportObjectDialog()
{
delete eo_ui_;
}
void ExportObjectDialog::show()
{
GString *error_msg;
if (!cap_file_) destroy(); // Assert?
/* Data will be gathered via a tap callback */
error_msg = register_tap_listener(tap_name_, (void *)&export_object_list_, NULL, 0,
eo_reset,
tap_packet_,
NULL);
if (error_msg) {
QMessageBox::warning(
this,
tr("Tap registration error"),
QString("Unable to register ") + name_ + QString(" tap: ") + error_msg->str,
QMessageBox::Ok
);
g_string_free(error_msg, TRUE);
return;
}
QDialog::show();
cf_retap_packets(cap_file_);
eo_ui_->progressFrame->hide();
for (int i = 0; i < eo_ui_->objectTree->columnCount(); i++)
eo_ui_->objectTree->resizeColumnToContents(i);
export_object_list_.eod = NULL;
remove_tap_listener((void *)&export_object_list_);
}
void ExportObjectDialog::addObjectEntry(export_object_entry_t *entry)
@ -191,6 +166,37 @@ void ExportObjectDialog::resetObjects()
if (save_all_bt_) save_all_bt_->setEnabled(false);
}
void ExportObjectDialog::show()
{
GString *error_msg;
if (!cap_file_) destroy(); // Assert?
/* Data will be gathered via a tap callback */
error_msg = register_tap_listener(tap_name_, (void *)&export_object_list_, NULL, 0,
eo_reset,
tap_packet_,
NULL);
if (error_msg) {
QMessageBox::warning(
this,
tr("Tap registration error"),
QString("Unable to register ") + name_ + QString(" tap: ") + error_msg->str,
QMessageBox::Ok
);
g_string_free(error_msg, TRUE);
return;
}
QDialog::show();
cf_retap_packets(cap_file_);
eo_ui_->progressFrame->hide();
for (int i = 0; i < eo_ui_->objectTree->columnCount(); i++)
eo_ui_->objectTree->resizeColumnToContents(i);
}
void ExportObjectDialog::accept()
{
// Don't close the dialog.

View File

@ -62,12 +62,14 @@ public:
explicit ExportObjectDialog(QWidget *parent, capture_file *cf, ObjectType object_type);
~ExportObjectDialog();
void show();
void addObjectEntry(export_object_entry_t *entry);
export_object_entry_t *objectEntry(int row);
void resetObjects();
public slots:
void show();
private slots:
void accept();
void captureFileClosing(const capture_file *cf);

View File

@ -801,20 +801,17 @@ void MainWindow::on_actionFileExportSSLSessionKeys_triggered()
void MainWindow::on_actionFileExportObjectsDICOM_triggered()
{
ExportObjectDialog *eod = new ExportObjectDialog(this, cap_file_, ExportObjectDialog::Dicom);
eod->show();
new ExportObjectDialog(this, cap_file_, ExportObjectDialog::Dicom);
}
void MainWindow::on_actionFileExportObjectsHTTP_triggered()
{
ExportObjectDialog *eod = new ExportObjectDialog(this, cap_file_, ExportObjectDialog::Http);
eod->show();
new ExportObjectDialog(this, cap_file_, ExportObjectDialog::Http);
}
void MainWindow::on_actionFileExportObjectsSMB_triggered()
{
ExportObjectDialog *eod = new ExportObjectDialog(this, cap_file_, ExportObjectDialog::Smb);
eod->show();
new ExportObjectDialog(this, cap_file_, ExportObjectDialog::Smb);
}
// View Menu