From 720f57d0009fd3941d327d30dc064adbc5feb5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Sat, 23 Jan 2016 13:18:30 +0100 Subject: [PATCH] ui: Code cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed code layout to use common style in the file. Mostly whitespace changes. Change-Id: Id37b57717a9e26248fad07322dff09b1d1f45ac2 Reviewed-on: https://code.wireshark.org/review/13504 Petri-Dish: Stig Bjørlykke Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/gtk/main_toolbar.c | 70 +++---- ui/qt/about_dialog.cpp | 13 +- ...bluetooth_att_server_attributes_dialog.cpp | 2 +- ui/qt/bluetooth_devices_dialog.cpp | 2 +- ui/qt/bluetooth_hci_summary_dialog.cpp | 2 +- ui/qt/byte_view_text.cpp | 2 +- ui/qt/capture_file_dialog.cpp | 4 +- ui/qt/capture_interfaces_dialog.cpp | 4 +- ui/qt/export_dissection_dialog.cpp | 7 +- ui/qt/follow_stream_dialog.cpp | 6 +- ui/qt/interface_tree.cpp | 14 +- ui/qt/main_status_bar.cpp | 2 +- ui/qt/main_welcome.cpp | 10 +- ui/qt/main_window.cpp | 179 ++++++++---------- ui/qt/main_window_slots.cpp | 29 +-- ui/qt/manage_interfaces_dialog.h | 2 +- ui/qt/packet_list.h | 2 +- ui/qt/print_dialog.cpp | 11 +- ui/qt/rtp_analysis_dialog.cpp | 26 +-- ui/qt/rtp_audio_stream.cpp | 2 +- ui/qt/sctp_chunk_statistics_dialog.cpp | 6 +- ui/qt/sctp_graph_dialog.cpp | 4 +- ui/qt/sparkline_delegate.cpp | 2 +- ui/qt/stats_tree_dialog.cpp | 4 +- ui/qt/tcp_stream_dialog.cpp | 2 +- ui/qt/traffic_table_dialog.cpp | 6 +- ui/qt/wlan_statistics_dialog.cpp | 2 +- 27 files changed, 188 insertions(+), 227 deletions(-) diff --git a/ui/gtk/main_toolbar.c b/ui/gtk/main_toolbar.c index cefe30e380..50275e6d3a 100644 --- a/ui/gtk/main_toolbar.c +++ b/ui/gtk/main_toolbar.c @@ -270,13 +270,12 @@ toolbar_auto_scroll_live_changed(gboolean auto_scroll_live_lcl) { static void plugin_if_maintoolbar_goto_frame(gconstpointer user_data) { - if ( user_data != NULL ) - { - GHashTable * dataSet = (GHashTable *) user_data; + if (user_data) { + GHashTable * data_set = (GHashTable *) user_data; gpointer framenr; - if ( g_hash_table_lookup_extended(dataSet, "frame_nr", NULL, &framenr ) ) - { - if ( GPOINTER_TO_UINT(framenr) != 0 ) + + if (g_hash_table_lookup_extended(data_set, "frame_nr", NULL, &framenr)) { + if (GPOINTER_TO_UINT(framenr) != 0) cf_goto_frame(&cfile, GPOINTER_TO_UINT(framenr)); } } @@ -286,48 +285,41 @@ plugin_if_maintoolbar_goto_frame(gconstpointer user_data) static void plugin_if_maintoolbar_get_ws_info(gconstpointer user_data) { - GHashTable * dataSet = (GHashTable *)user_data; + GHashTable * data_set = (GHashTable *)user_data; ws_info_t *ws_info = NULL; + capture_file *cf; - if (g_hash_table_lookup_extended(dataSet, "ws_info", NULL, (void**)&ws_info)) - { - capture_file *cf = &cfile; + if (!g_hash_table_lookup_extended(data_set, "ws_info", NULL, (void**)&ws_info)) + return; - if (cf->state != FILE_CLOSED) - { - ws_info->ws_info_supported = TRUE; - ws_info->cf_state = cf->state; - ws_info->cf_count = cf->count; + cf = &cfile; - if (ws_info->cf_filename != NULL) - g_free(ws_info->cf_filename); - ws_info->cf_filename = g_strdup(cf->filename); + if (cf->state != FILE_CLOSED) { + ws_info->ws_info_supported = TRUE; + ws_info->cf_state = cf->state; + ws_info->cf_count = cf->count; - if (cf->state == FILE_READ_DONE) - { - ws_info->cf_framenr = (cf->current_frame)->num; - ws_info->frame_passed_dfilter = ((cf->current_frame)->flags.passed_dfilter) == 0 ? FALSE : TRUE; - } - else - { - ws_info->cf_framenr = 0; - ws_info->frame_passed_dfilter = FALSE; - } - } - else if (ws_info->cf_state != FILE_CLOSED) - { - /* Initialise the ws_info structure */ - ws_info->ws_info_supported = TRUE; - ws_info->cf_count = 0; - - if (ws_info->cf_filename != NULL) - g_free(ws_info->cf_filename); - ws_info->cf_filename = NULL; + g_free(ws_info->cf_filename); + ws_info->cf_filename = g_strdup(cf->filename); + if (cf->state == FILE_READ_DONE) { + ws_info->cf_framenr = cf->current_frame->num; + ws_info->frame_passed_dfilter = (cf->current_frame->flags.passed_dfilter == 1); + } else { ws_info->cf_framenr = 0; ws_info->frame_passed_dfilter = FALSE; - ws_info->cf_state = FILE_CLOSED; } + } else if (ws_info->cf_state != FILE_CLOSED) { + /* Initialise the ws_info structure */ + ws_info->ws_info_supported = TRUE; + ws_info->cf_count = 0; + + g_free(ws_info->cf_filename); + ws_info->cf_filename = NULL; + + ws_info->cf_framenr = 0; + ws_info->frame_passed_dfilter = FALSE; + ws_info->cf_state = FILE_CLOSED; } } diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp index 84cbcee10f..19510ce16c 100644 --- a/ui/qt/about_dialog.cpp +++ b/ui/qt/about_dialog.cpp @@ -86,7 +86,7 @@ const QString AboutDialog::about_folders_row(const char *name, const QString dir static void plugins_add_description(const char *name, const char *version, const char *types, const char *filename, - void *user_data ) + void *user_data) { QList *plugin_data = (QList *)user_data; QStringList plugin_row = QStringList() << name << version << types << filename; @@ -120,15 +120,12 @@ const QString AboutDialog::plugins_scan() } GHashTable * tools = extcap_tools_list(); - if ( tools != NULL && g_hash_table_size(tools) > 0 ) - { + if (tools && g_hash_table_size(tools) > 0) { QString short_file; GList * walker = g_list_first(g_hash_table_get_keys(tools)); - while ( walker ) - { + while (walker) { extcap_info * tool = (extcap_info *)g_hash_table_lookup(tools, walker->data); - if ( tool != NULL ) - { + if (tool) { short_file = fontMetrics().elidedText(tool->full_path, Qt::ElideMiddle, one_em*22); plugin_table += QString("%1%2%3%4\n") .arg(tool->basename) // Name @@ -184,7 +181,7 @@ AboutDialog::AboutDialog(QWidget *parent) : /* Check if it is a dev release... (VERSION_MINOR is odd in dev release) */ #if VERSION_MINOR & 1 - ui->label_logo->setPixmap( QPixmap( ":/about/wssplash_dev.png" ) ); + ui->label_logo->setPixmap(QPixmap(":/about/wssplash_dev.png")); #endif diff --git a/ui/qt/bluetooth_att_server_attributes_dialog.cpp b/ui/qt/bluetooth_att_server_attributes_dialog.cpp index cbb3673efa..2b787552da 100644 --- a/ui/qt/bluetooth_att_server_attributes_dialog.cpp +++ b/ui/qt/bluetooth_att_server_attributes_dialog.cpp @@ -164,7 +164,7 @@ void BluetoothAttServerAttributesDialog::on_actionCopy_Rows_triggered() clipboard->setText(copy); } -void BluetoothAttServerAttributesDialog::tapReset(void *tapinfo_ptr ) +void BluetoothAttServerAttributesDialog::tapReset(void *tapinfo_ptr) { tapinfo_t *tapinfo = (tapinfo_t *) tapinfo_ptr; BluetoothAttServerAttributesDialog *bluetooth_att_server_attributes_dialog = static_cast(tapinfo->ui); diff --git a/ui/qt/bluetooth_devices_dialog.cpp b/ui/qt/bluetooth_devices_dialog.cpp index 063af1bbe3..4991b8e22b 100644 --- a/ui/qt/bluetooth_devices_dialog.cpp +++ b/ui/qt/bluetooth_devices_dialog.cpp @@ -182,7 +182,7 @@ void BluetoothDevicesDialog::on_actionCopy_Rows_triggered() clipboard->setText(copy); } -void BluetoothDevicesDialog::tapReset(void *tapinfo_ptr ) +void BluetoothDevicesDialog::tapReset(void *tapinfo_ptr) { bluetooth_devices_tapinfo_t *tapinfo = (bluetooth_devices_tapinfo_t *) tapinfo_ptr; BluetoothDevicesDialog *bluetooth_devices_dialog = static_cast(tapinfo->ui); diff --git a/ui/qt/bluetooth_hci_summary_dialog.cpp b/ui/qt/bluetooth_hci_summary_dialog.cpp index 7f6933dfb6..035735837d 100644 --- a/ui/qt/bluetooth_hci_summary_dialog.cpp +++ b/ui/qt/bluetooth_hci_summary_dialog.cpp @@ -239,7 +239,7 @@ void BluetoothHciSummaryDialog::on_actionCopy_Rows_triggered() clipboard->setText(copy); } -void BluetoothHciSummaryDialog::tapReset(void *tapinfo_ptr ) +void BluetoothHciSummaryDialog::tapReset(void *tapinfo_ptr) { bluetooth_hci_summary_tapinfo_t *tapinfo = (bluetooth_hci_summary_tapinfo_t *) tapinfo_ptr; BluetoothHciSummaryDialog *dialog = static_cast(tapinfo->ui); diff --git a/ui/qt/byte_view_text.cpp b/ui/qt/byte_view_text.cpp index 8f05a3d087..58ad98d126 100644 --- a/ui/qt/byte_view_text.cpp +++ b/ui/qt/byte_view_text.cpp @@ -218,7 +218,7 @@ void ByteViewText::resizeEvent(QResizeEvent *) } void ByteViewText::mousePressEvent (QMouseEvent *event) { - if (!tvb_ || !event || event->button() != Qt::LeftButton ) { + if (!tvb_ || !event || event->button() != Qt::LeftButton) { return; } diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp index c4a838abeb..aecc2975aa 100644 --- a/ui/qt/capture_file_dialog.cpp +++ b/ui/qt/capture_file_dialog.cpp @@ -791,7 +791,7 @@ void CaptureFileDialog::preview(const QString & path) preview_size_.setText(QString(tr("%1 bytes")).arg(wtap_file_size(wth, &err))); time(&time_preview); - while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) { + while ((wtap_read(wth, &err, &err_info, &data_offset))) { phdr = wtap_phdr(wth); cur_time = nstime_to_sec(&phdr->ts); if(packets == 0) { @@ -830,7 +830,7 @@ void CaptureFileDialog::preview(const QString & path) // First packet ti_time = (long)start_time; - ti_tm = localtime( &ti_time ); + ti_tm = localtime(&ti_time); if(ti_tm) { preview_first_.setText(QString().sprintf( "%04d-%02d-%02d %02d:%02d:%02d", diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp index 031b89e7b1..e18bd50bf8 100644 --- a/ui/qt/capture_interfaces_dialog.cpp +++ b/ui/qt/capture_interfaces_dialog.cpp @@ -931,7 +931,7 @@ InterfaceTreeDelegate::~InterfaceTreeDelegate() } -QWidget* InterfaceTreeDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index ) const +QWidget* InterfaceTreeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const { QWidget *w = NULL; #ifdef SHOW_BUFFER_COLUMN @@ -1040,7 +1040,7 @@ bool InterfaceTreeDelegate::eventFilter(QObject *object, QEvent *event) return true; } } else { - return QStyledItemDelegate::eventFilter( object, event ); + return QStyledItemDelegate::eventFilter(object, event); } return false; } diff --git a/ui/qt/export_dissection_dialog.cpp b/ui/qt/export_dissection_dialog.cpp index 14a7acb4e4..afd84243cc 100644 --- a/ui/qt/export_dissection_dialog.cpp +++ b/ui/qt/export_dissection_dialog.cpp @@ -235,9 +235,10 @@ void ExportDissectionDialog::checkValidity() if (!packet_range_group_box_.isValid()) enable = false; if (export_type_ == export_type_text) { - if ( ! packet_format_group_box_.summaryEnabled() && - ! packet_format_group_box_.detailsEnabled() && - ! packet_format_group_box_.bytesEnabled() ) { + if (! packet_format_group_box_.summaryEnabled() && + ! packet_format_group_box_.detailsEnabled() && + ! packet_format_group_box_.bytesEnabled()) + { enable = false; } } diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp index acbda38bf1..c126c0da3f 100644 --- a/ui/qt/follow_stream_dialog.cpp +++ b/ui/qt/follow_stream_dialog.cpp @@ -145,7 +145,7 @@ void FollowStreamDialog::printStream() #ifndef QT_NO_PRINTER QPrinter printer(QPrinter::HighResolution); QPrintDialog dialog(&printer, this); - if ( dialog.exec() == QDialog::Accepted) + if (dialog.exec() == QDialog::Accepted) ui->teStreamContent->print(&printer); #endif } @@ -239,7 +239,7 @@ void FollowStreamDialog::saveAs() QString file_name = QFileDialog::getSaveFileName(this, wsApp->windowTitleString(tr("Save Stream Content As" UTF8_HORIZONTAL_ELLIPSIS))); if (!file_name.isEmpty()) { file_.setFileName(file_name); - file_.open( QIODevice::WriteOnly ); + file_.open(QIODevice::WriteOnly); QTextStream out(&file_); save_as_ = true; @@ -640,7 +640,7 @@ FollowStreamDialog::showBuffer(char *buffer, size_t nchars, gboolean is_from_ser for (i = 0; i < 16 && current_pos + i < nchars; i++) { *cur++ = (g_ascii_isprint((guchar)buffer[current_pos + i]) ? - buffer[current_pos + i] : '.' ); + buffer[current_pos + i] : '.'); if (i == 7) { *cur++ = ' '; } diff --git a/ui/qt/interface_tree.cpp b/ui/qt/interface_tree.cpp index 900bb64976..f88e96ea4d 100644 --- a/ui/qt/interface_tree.cpp +++ b/ui/qt/interface_tree.cpp @@ -56,7 +56,7 @@ InterfaceTree::InterfaceTree(QWidget *parent) : { QTreeWidgetItem *ti; - qRegisterMetaType< PointList >( "PointList" ); + qRegisterMetaType< PointList >("PointList"); header()->setVisible(false); setRootIsDecorated(false); @@ -191,19 +191,17 @@ void InterfaceTree::display() ti->setData(IFTREE_COL_NAME, Qt::UserRole, QString(device.name)); ti->setData(IFTREE_COL_STATS, Qt::UserRole, qVariantFromValue(&ti->points)); #if HAVE_EXTCAP - if ( device.if_info.type == IF_EXTCAP ) - { - if ( extcap_has_configuration((const char *)(device.name), FALSE) ) - { + if (device.if_info.type == IF_EXTCAP) { + if (extcap_has_configuration((const char *)(device.name), FALSE)) { ti->setIcon(IFTREE_COL_EXTCAP, extcap_icon); ti->setData(IFTREE_COL_EXTCAP, Qt::UserRole, QString(device.if_info.extcap)); - if ( !(device.external_cap_args_settings != 0 && - g_hash_table_size(device.external_cap_args_settings ) > 0) ) + if (!(device.external_cap_args_settings != 0 && + g_hash_table_size(device.external_cap_args_settings) > 0)) { QFont ti_font = ti->font(IFTREE_COL_NAME); ti_font.setItalic(true); - ti->setFont(IFTREE_COL_NAME, ti_font ); + ti->setFont(IFTREE_COL_NAME, ti_font); } } virt_ifaces << ti; diff --git a/ui/qt/main_status_bar.cpp b/ui/qt/main_status_bar.cpp index a1ccba2110..3ebba65a49 100644 --- a/ui/qt/main_status_bar.cpp +++ b/ui/qt/main_status_bar.cpp @@ -282,7 +282,7 @@ void MainStatusBar::popTemporaryStatus() { info_status_.popText(STATUS_CTX_TEMPORARY); } -void MainStatusBar::pushFileStatus(const QString &message, const QString &messagetip ) { +void MainStatusBar::pushFileStatus(const QString &message, const QString &messagetip) { info_status_.pushText(message, STATUS_CTX_FILE); info_status_.setToolTip(messagetip); expertUpdate(); diff --git a/ui/qt/main_welcome.cpp b/ui/qt/main_welcome.cpp index 4ab8031986..87341b6869 100644 --- a/ui/qt/main_welcome.cpp +++ b/ui/qt/main_welcome.cpp @@ -241,10 +241,10 @@ void MainWelcome::interfaceDoubleClicked(QTreeWidgetItem *item, int) QString extcap_string = QVariant(item->data(IFTREE_COL_EXTCAP, Qt::UserRole)).toString(); /* We trust the string here. If this interface is really extcap, the string is * being checked immediatly before the dialog is being generated */ - if ( extcap_string.length() > 0 ) { + if (extcap_string.length() > 0) { QString device_name = QVariant(item->data(IFTREE_COL_NAME, Qt::UserRole)).toString(); /* this checks if configuration is required and not yet provided or saved via prefs */ - if ( extcap_has_configuration((const char *)(device_name.toStdString().c_str()), TRUE ) ) { + if (extcap_has_configuration((const char *)(device_name.toStdString().c_str()), TRUE)) { emit showExtcapOptions(device_name); return; } @@ -257,13 +257,11 @@ void MainWelcome::interfaceDoubleClicked(QTreeWidgetItem *item, int) void MainWelcome::interfaceClicked(QTreeWidgetItem *item, int column) { #if HAVE_EXTCAP - if ( column == IFTREE_COL_EXTCAP ) - { + if (column == IFTREE_COL_EXTCAP) { QString extcap_string = QVariant(item->data(IFTREE_COL_EXTCAP, Qt::UserRole)).toString(); /* We trust the string here. If this interface is really extcap, the string is * being checked immediatly before the dialog is being generated */ - if ( extcap_string.length() > 0 ) - { + if (extcap_string.length() > 0) { QString device_name = QVariant(item->data(IFTREE_COL_NAME, Qt::UserRole)).toString(); emit showExtcapOptions(device_name); } diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 32d165b013..c9063c4efd 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -89,51 +89,49 @@ void pipe_input_set_handler(gint source, gpointer user_data, ws_process_id *chil static void plugin_if_mainwindow_apply_filter(gconstpointer user_data) { - if ( gbl_cur_main_window_ != NULL && user_data != NULL ) - { - GHashTable * dataSet = (GHashTable *) user_data; + if (!gbl_cur_main_window_ || !user_data) + return; - if ( g_hash_table_lookup_extended(dataSet, "filter_string", NULL, NULL ) ) - { - QString filter((const char *)g_hash_table_lookup(dataSet, "filter_string")); - gbl_cur_main_window_->filterPackets(filter); - } + GHashTable * data_set = (GHashTable *) user_data; + + if (g_hash_table_lookup_extended(data_set, "filter_string", NULL, NULL)) { + QString filter((const char *)g_hash_table_lookup(data_set, "filter_string")); + gbl_cur_main_window_->filterPackets(filter); } } static void plugin_if_mainwindow_preference(gconstpointer user_data) { - if ( gbl_cur_main_window_ != NULL && user_data != NULL ) + if (!gbl_cur_main_window_ || !user_data) + return; + + GHashTable * data_set = (GHashTable *) user_data; + const char * module_name; + const char * pref_name; + const char * pref_value; + + if (g_hash_table_lookup_extended(data_set, "pref_module", NULL, (void**)&module_name) && + g_hash_table_lookup_extended(data_set, "pref_key", NULL, (void**)&pref_name) && + g_hash_table_lookup_extended(data_set, "pref_value", NULL, (void**)&pref_value)) { - GHashTable * dataSet = (GHashTable *) user_data; - const char * module_name; - const char * pref_name; - const char * pref_value; - if ( g_hash_table_lookup_extended(dataSet, "pref_module", NULL, (void**)&module_name ) && - g_hash_table_lookup_extended(dataSet, "pref_key", NULL, (void**)&pref_name ) && - g_hash_table_lookup_extended(dataSet, "pref_value", NULL, (void**)&pref_value ) ) - { - if ( prefs_store_ext(module_name, pref_name, pref_value) ) - { - wsApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged); - wsApp->emitAppSignal(WiresharkApplication::PreferencesChanged); - } + if (prefs_store_ext(module_name, pref_name, pref_value)) { + wsApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged); + wsApp->emitAppSignal(WiresharkApplication::PreferencesChanged); } } } static void plugin_if_mainwindow_gotoframe(gconstpointer user_data) { - if ( gbl_cur_main_window_ != NULL && user_data != NULL ) - { - GHashTable * dataSet = (GHashTable *) user_data; - gpointer framenr; + if (!gbl_cur_main_window_ || !user_data) + return; - if ( g_hash_table_lookup_extended(dataSet, "frame_nr", NULL, &framenr ) ) - { - if ( GPOINTER_TO_UINT(framenr) != 0 ) - gbl_cur_main_window_->gotoFrame(GPOINTER_TO_UINT(framenr)); - } + GHashTable * data_set = (GHashTable *) user_data; + gpointer framenr; + + if (g_hash_table_lookup_extended(data_set, "frame_nr", NULL, &framenr)) { + if (GPOINTER_TO_UINT(framenr) != 0) + gbl_cur_main_window_->gotoFrame(GPOINTER_TO_UINT(framenr)); } } @@ -141,52 +139,44 @@ static void plugin_if_mainwindow_gotoframe(gconstpointer user_data) static void plugin_if_mainwindow_get_ws_info(gconstpointer user_data) { - if (gbl_cur_main_window_ != NULL && user_data != NULL) - { - GHashTable * dataSet = (GHashTable *)user_data; - ws_info_t *ws_info = NULL; + if (!gbl_cur_main_window_ || !user_data) + return; - if (g_hash_table_lookup_extended(dataSet, "ws_info", NULL, (void**)&ws_info)) - { - CaptureFile *cfWrap = gbl_cur_main_window_->captureFile(); - capture_file *cf = cfWrap->capFile(); + GHashTable * data_set = (GHashTable *)user_data; + ws_info_t *ws_info = NULL; - ws_info->ws_info_supported = true; + if (!g_hash_table_lookup_extended(data_set, "ws_info", NULL, (void**)&ws_info)) + return; - if (cf != NULL) - { - ws_info->cf_state = cf->state; - ws_info->cf_count = cf->count; + CaptureFile *cfWrap = gbl_cur_main_window_->captureFile(); + capture_file *cf = cfWrap->capFile(); - if (ws_info->cf_filename != NULL) - g_free(ws_info->cf_filename); - ws_info->cf_filename = g_strdup(cf->filename); + ws_info->ws_info_supported = true; - if (cf->state == FILE_READ_DONE) - { - ws_info->cf_framenr = (cf->current_frame)->num; - ws_info->frame_passed_dfilter = ((cf->current_frame)->flags.passed_dfilter) == 0 ? FALSE : TRUE; - } - else - { - ws_info->cf_framenr = 0; - ws_info->frame_passed_dfilter = FALSE; - } - } - else if (ws_info->cf_state != FILE_CLOSED) - { - /* Initialise the ws_info structure */ - ws_info->cf_count = 0; + if (cf) { + ws_info->cf_state = cf->state; + ws_info->cf_count = cf->count; - if (ws_info->cf_filename != NULL) - g_free(ws_info->cf_filename); - ws_info->cf_filename = NULL; + g_free(ws_info->cf_filename); + ws_info->cf_filename = g_strdup(cf->filename); - ws_info->cf_framenr = 0; - ws_info->frame_passed_dfilter = false; - ws_info->cf_state = FILE_CLOSED; - } + if (cf->state == FILE_READ_DONE) { + ws_info->cf_framenr = cf->current_frame->num; + ws_info->frame_passed_dfilter = (cf->current_frame->flags.passed_dfilter == 1); + } else { + ws_info->cf_framenr = 0; + ws_info->frame_passed_dfilter = FALSE; } + } else if (ws_info->cf_state != FILE_CLOSED) { + /* Initialise the ws_info structure */ + ws_info->cf_count = 0; + + g_free(ws_info->cf_filename); + ws_info->cf_filename = NULL; + + ws_info->cf_framenr = 0; + ws_info->frame_passed_dfilter = FALSE; + ws_info->cf_state = FILE_CLOSED; } } @@ -669,8 +659,8 @@ MainWindow::MainWindow(QWidget *parent) : #endif /* Create plugin_if hooks */ - plugin_if_register_gui_cb(PLUGIN_IF_FILTER_ACTION_APPLY, plugin_if_mainwindow_apply_filter ); - plugin_if_register_gui_cb(PLUGIN_IF_FILTER_ACTION_PREPARE, plugin_if_mainwindow_apply_filter ); + plugin_if_register_gui_cb(PLUGIN_IF_FILTER_ACTION_APPLY, plugin_if_mainwindow_apply_filter); + plugin_if_register_gui_cb(PLUGIN_IF_FILTER_ACTION_PREPARE, plugin_if_mainwindow_apply_filter); plugin_if_register_gui_cb(PLUGIN_IF_PREFERENCE_SAVE, plugin_if_mainwindow_preference); plugin_if_register_gui_cb(PLUGIN_IF_GOTO_FRAME, plugin_if_mainwindow_gotoframe); #ifdef HAVE_LIBPCAP @@ -1950,17 +1940,17 @@ void MainWindow::setWSWindowTitle(QString title) } if (prefs.gui_prepend_window_title && prefs.gui_prepend_window_title[0]) { - QString customTitle = replaceWindowTitleVariables(prefs.gui_prepend_window_title); - title.prepend(QString("[%1] ").arg(customTitle)); + QString custom_title = replaceWindowTitleVariables(prefs.gui_prepend_window_title); + title.prepend(QString("[%1] ").arg(custom_title)); } if (prefs.gui_window_title && prefs.gui_window_title[0]) { - QString customTitle = replaceWindowTitleVariables(prefs.gui_window_title); + QString custom_title = replaceWindowTitleVariables(prefs.gui_window_title); #ifdef __APPLE__ // On OS X we separate the titles with a unicode em dash - title.append(QString(" %1 %2").arg(UTF8_EM_DASH).arg(customTitle)); + title.append(QString(" %1 %2").arg(UTF8_EM_DASH).arg(custom_title)); #else - title.append(QString(" [%1]").arg(customTitle)); + title.append(QString(" [%1]").arg(custom_title)); #endif } @@ -2356,21 +2346,15 @@ void MainWindow::externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, gint de children = menu->children; /* Iterate the child entries */ - while ( children != NULL && children->data != NULL ) - { + while (children && children->data) { item = (ext_menubar_t *) children->data; - if ( item->type == EXT_MENUBAR_MENU ) - { + if (item->type == EXT_MENUBAR_MENU) { /* Handle Submenu entry */ - this->externalMenuHelper(item, subMenu->addMenu(item->label), depth++ ); - } - else if ( item->type == EXT_MENUBAR_SEPARATOR ) - { + this->externalMenuHelper(item, subMenu->addMenu(item->label), depth++); + } else if (item->type == EXT_MENUBAR_SEPARATOR) { subMenu->addSeparator(); - } - else if ( item->type == EXT_MENUBAR_ITEM || item->type == EXT_MENUBAR_URL ) - { + } else if (item->type == EXT_MENUBAR_ITEM || item->type == EXT_MENUBAR_URL) { itemAction = subMenu->addAction(item->name); itemAction->setData(QVariant::fromValue((void *)item)); itemAction->setText(item->label); @@ -2387,14 +2371,12 @@ QMenu * MainWindow::searchSubMenu(QString objectName) { QList lst; - if ( objectName.length() > 0 ) - { + if (objectName.length() > 0) { QString searchName = QString("menu") + objectName; lst = main_ui_->menuBar->findChildren(); - foreach (QMenu* m, lst) - { - if ( QString::compare( m->objectName(), searchName ) == 0 ) + foreach (QMenu* m, lst) { + if (QString::compare(m->objectName(), searchName) == 0) return m; } } @@ -2410,27 +2392,24 @@ void MainWindow::addExternalMenus() user_menu = ext_menubar_get_entries(); - while ( ( user_menu != NULL ) && ( user_menu->data != NULL ) ) - { + while (user_menu && user_menu->data) { menu = (ext_menu_t *) user_menu->data; /* On this level only menu items should exist. Not doing an assert here, * as it could be an honest mistake */ - if ( menu->type != EXT_MENUBAR_MENU ) - { + if (menu->type != EXT_MENUBAR_MENU) { user_menu = g_list_next(user_menu); continue; } /* Create main submenu and add it to the menubar */ - if ( menu->parent_menu != NULL ) - { + if (menu->parent_menu) { QMenu * sortUnderneath = searchSubMenu(QString(menu->parent_menu)); - if ( sortUnderneath != NULL) + if (sortUnderneath) subMenu = sortUnderneath->addMenu(menu->label); } - if ( subMenu == NULL ) + if (!subMenu) subMenu = main_ui_->menuBar->addMenu(menu->label); /* This will generate the action structure for each menu. It is recursive, diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index bf59333d8e..b58fe1aa5e 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -2369,7 +2369,7 @@ void MainWindow::colorizeConversation(bool create_rule) if ((color_filter != NULL) && (color_filter->is_filter_valid(pi))) filter = color_filter->build_filter_string(pi); } - if( filter == NULL ) { + if (filter == NULL) { main_ui_->statusBar->pushTemporaryStatus(tr("Unable to build conversation filter.")); return; } @@ -2578,8 +2578,7 @@ void MainWindow::on_actionAnalyzeCreateAColumn_triggered() { gint colnr = 0; - if ( capture_file_.capFile() != 0 && capture_file_.capFile()->finfo_selected != 0 ) - { + if (capture_file_.capFile() != 0 && capture_file_.capFile()->finfo_selected != 0) { colnr = column_prefs_add_custom(COL_CUSTOM, capture_file_.capFile()->finfo_selected->hfinfo->name, capture_file_.capFile()->finfo_selected->hfinfo->abbrev,0); @@ -3430,7 +3429,7 @@ void MainWindow::goToConversationFrame(bool go_next) { if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi))) filter = conv_filter->build_filter_string(pi); - if( filter == NULL ) { + if (filter == NULL) { main_ui_->statusBar->pushTemporaryStatus(tr("Unable to build conversation filter.")); g_free(filter); return; @@ -3624,21 +3623,16 @@ void MainWindow::externalMenuItem_triggered() QVariant v; ext_menubar_t * entry = NULL; - if ( QObject::sender() != NULL) - { + if (QObject::sender()) { triggerAction = (QAction *)QObject::sender(); v = triggerAction->data(); - if ( v.canConvert()) - { + if (v.canConvert()) { entry = (ext_menubar_t *)v.value(); - if ( entry->type == EXT_MENUBAR_ITEM ) - { + if (entry->type == EXT_MENUBAR_ITEM) { entry->callback(EXT_MENUBAR_QT_GUI, (gpointer) ((void *)main_ui_), entry->user_data); - } - else - { + } else { QDesktopServices::openUrl(QUrl(QString((gchar *)entry->user_data))); } } @@ -3647,8 +3641,7 @@ void MainWindow::externalMenuItem_triggered() void MainWindow::gotoFrame(int packet_num) { - if ( packet_num > 0 ) - { + if (packet_num > 0) { packet_list_->goToPacket(packet_num); } } @@ -3656,8 +3649,7 @@ void MainWindow::gotoFrame(int packet_num) #ifdef HAVE_EXTCAP void MainWindow::extcap_options_finished(int result) { - if ( result == QDialog::Accepted ) - { + if (result == QDialog::Accepted) { startCapture(); } this->main_welcome_->getInterfaceTree()->interfaceListChanged(); @@ -3667,8 +3659,7 @@ void MainWindow::showExtcapOptionsDialog(QString &device_name) { ExtcapOptionsDialog * extcap_options_dialog = ExtcapOptionsDialog::createForDevice(device_name, this); /* The dialog returns null, if the given device name is not a valid extcap device */ - if ( extcap_options_dialog != NULL ) - { + if (extcap_options_dialog) { connect(extcap_options_dialog, SIGNAL(finished(int)), this, SLOT(extcap_options_finished(int))); extcap_options_dialog->show(); diff --git a/ui/qt/manage_interfaces_dialog.h b/ui/qt/manage_interfaces_dialog.h index 4d078e7342..57883dedc8 100644 --- a/ui/qt/manage_interfaces_dialog.h +++ b/ui/qt/manage_interfaces_dialog.h @@ -54,7 +54,7 @@ public: protected: QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; - void updateEditorGeometry ( QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index ) const; + void updateEditorGeometry (QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const; private slots: void stopEditor(); diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h index 9e825fbed0..2c11029bff 100644 --- a/ui/qt/packet_list.h +++ b/ui/qt/packet_list.h @@ -86,7 +86,7 @@ protected: protected slots: void rowsInserted(const QModelIndex &parent, int start, int end); - void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const; + void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; private: PacketListModel *packet_list_model_; diff --git a/ui/qt/print_dialog.cpp b/ui/qt/print_dialog.cpp index 12719771dc..58f4cb0bba 100644 --- a/ui/qt/print_dialog.cpp +++ b/ui/qt/print_dialog.cpp @@ -279,11 +279,12 @@ void PrintDialog::checkValidity() if (!pd_ui_->rangeGroupBox->isValid()) enable = false; - if ( ! pd_ui_->formatGroupBox->summaryEnabled() && - ! pd_ui_->formatGroupBox->detailsEnabled() && - ! pd_ui_->formatGroupBox->bytesEnabled() ) { - enable = false; - } + if (!pd_ui_->formatGroupBox->summaryEnabled() && + !pd_ui_->formatGroupBox->detailsEnabled() && + !pd_ui_->formatGroupBox->bytesEnabled()) + { + enable = false; + } print_bt_->setEnabled(enable); preview_->updatePreview(); diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp index 25abf9927c..04ddece52c 100644 --- a/ui/qt/rtp_analysis_dialog.cpp +++ b/ui/qt/rtp_analysis_dialog.cpp @@ -743,13 +743,15 @@ void RtpAnalysisDialog::savePayload(QTemporaryFile *tmpfile, tap_rtp_stat_t *sta /* Save the voice information */ /* If there was already an error, we quit */ - if (!tmpfile->isOpen() || tmpfile->error() != QFile::NoError) return; + if (!tmpfile->isOpen() || tmpfile->error() != QFile::NoError) + return; /* Quit if the captured length and packet length aren't equal or * if the RTP dissector thinks there is some information missing */ - if ((pinfo->fd->pkt_len != pinfo->fd->cap_len) - && (!rtpinfo->info_all_data_present)) { + if ((pinfo->fd->pkt_len != pinfo->fd->cap_len) && + (!rtpinfo->info_all_data_present)) + { tmpfile->close(); err_str_ = tr("Can't save in a file: Wrong length of captured packets."); return; @@ -758,18 +760,20 @@ void RtpAnalysisDialog::savePayload(QTemporaryFile *tmpfile, tap_rtp_stat_t *sta /* If padding bit is set but the padding count is bigger * then the whole RTP data - error with padding count */ - if ( (rtpinfo->info_padding_set != FALSE) - && (rtpinfo->info_padding_count > rtpinfo->info_payload_len) ) { + if ((rtpinfo->info_padding_set != FALSE) && + (rtpinfo->info_padding_count > rtpinfo->info_payload_len)) + { tmpfile->close(); err_str_ = tr("Can't save in a file: RTP data with padding."); return; } /* Do we need to insert some silence? */ - if ((rtpinfo->info_marker_set) - && ! (statinfo->flags & STAT_FLAG_FIRST) - && ! (statinfo->flags & STAT_FLAG_WRONG_TIMESTAMP) - && (statinfo->delta_timestamp > (rtpinfo->info_payload_len - rtpinfo->info_padding_count)) ) { + if ((rtpinfo->info_marker_set) && + !(statinfo->flags & STAT_FLAG_FIRST) && + !(statinfo->flags & STAT_FLAG_WRONG_TIMESTAMP) && + (statinfo->delta_timestamp > (rtpinfo->info_payload_len - rtpinfo->info_padding_count))) + { /* the amount of silence should be the difference between * the last timestamp and the current one minus x * x should equal the amount of information in the last frame @@ -803,8 +807,8 @@ void RtpAnalysisDialog::savePayload(QTemporaryFile *tmpfile, tap_rtp_stat_t *sta } - if ((rtpinfo->info_payload_type == PT_CN) - || (rtpinfo->info_payload_type == PT_CN_OLD)) { + if ((rtpinfo->info_payload_type == PT_CN) || + (rtpinfo->info_payload_type == PT_CN_OLD)) { } else { /* All other payloads */ const char *data; size_t nchars; diff --git a/ui/qt/rtp_audio_stream.cpp b/ui/qt/rtp_audio_stream.cpp index e3158f0e2e..7ccaba690c 100644 --- a/ui/qt/rtp_audio_stream.cpp +++ b/ui/qt/rtp_audio_stream.cpp @@ -264,7 +264,7 @@ void RtpAudioStream::decode() RTP_STREAM_DEBUG("Packet drop by jitter buffer exceeded %f > %d", diff*1000, jitter_buffer_size_); /* if there was a silence period (more than two packetization period) resync the source */ - if ( (rtp_time - rtp_time_prev) > pack_period*2 ){ + if ((rtp_time - rtp_time_prev) > pack_period*2) { int silence_samples; RTP_STREAM_DEBUG("Resync..."); diff --git a/ui/qt/sctp_chunk_statistics_dialog.cpp b/ui/qt/sctp_chunk_statistics_dialog.cpp index 9a20381c4c..839518ff96 100644 --- a/ui/qt/sctp_chunk_statistics_dialog.cpp +++ b/ui/qt/sctp_chunk_statistics_dialog.cpp @@ -100,7 +100,7 @@ void SCTPChunkStatisticsDialog::fillTable(bool all) gchar* fname = uat_get_actual_filename(uat,TRUE); bool init = false; - if (!fname ) { + if (!fname) { init = true; } else { fp = ws_fopen(fname,"r"); @@ -192,7 +192,7 @@ void SCTPChunkStatisticsDialog::fillTable(bool all) fclose(fp); } -void SCTPChunkStatisticsDialog::contextMenuEvent( QContextMenuEvent * event) +void SCTPChunkStatisticsDialog::contextMenuEvent(QContextMenuEvent * event) { selected_point = event->pos(); QTableWidgetItem *item = ui->tableWidget->itemAt(selected_point.x(), selected_point.y()-60); @@ -213,7 +213,7 @@ void SCTPChunkStatisticsDialog::on_pushButton_clicked() gchar* fname = uat_get_actual_filename(uat,TRUE); - if (!fname ) { + if (!fname) { return; } fp = ws_fopen(fname,"w"); diff --git a/ui/qt/sctp_graph_dialog.cpp b/ui/qt/sctp_graph_dialog.cpp index d0efcf5f57..2fa2aca04a 100644 --- a/ui/qt/sctp_graph_dialog.cpp +++ b/ui/qt/sctp_graph_dialog.cpp @@ -102,12 +102,12 @@ void SCTPGraphDialog::drawNRSACKGraph() tsnumber = g_ntohl(nr_sack_header->cum_tsn_ack); total_gaps = numberOf_gaps + numberOf_nr_gaps; /* If the number of nr_gaps is greater than 0 */ - if ( total_gaps > 0 ) { + if (total_gaps > 0) { nr_gap = &nr_sack_header->gaps[0]; for (i = 0; i < total_gaps; i++) { gap_start = g_ntohs(nr_gap->start); gap_end = g_ntohs(nr_gap->end); - for ( j = gap_start; j <= gap_end; j++) { + for (j = gap_start; j <= gap_end; j++) { if (i >= numberOf_gaps) { yn.append(j + tsnumber); xn.append(sack->secs + sack->usecs/1000000.0); diff --git a/ui/qt/sparkline_delegate.cpp b/ui/qt/sparkline_delegate.cpp index 3407dc3e40..3cc4069192 100644 --- a/ui/qt/sparkline_delegate.cpp +++ b/ui/qt/sparkline_delegate.cpp @@ -55,7 +55,7 @@ void SparkLineDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt } foreach (val, *points) { - fpoints.append(QPointF(idx, (qreal) content_h - (val * content_h / max) )); + fpoints.append(QPointF(idx, (qreal) content_h - (val * content_h / max))); idx = idx + step_w; } diff --git a/ui/qt/stats_tree_dialog.cpp b/ui/qt/stats_tree_dialog.cpp index 4f998568a9..841efde44b 100644 --- a/ui/qt/stats_tree_dialog.cpp +++ b/ui/qt/stats_tree_dialog.cpp @@ -183,8 +183,8 @@ void StatsTreeDialog::drawTreeItems(void *st_ptr) (*iter)->setText(count,valstrs[count]); g_free(valstrs[count]); } - (*iter)->setExpanded( (node->parent==(&st->root)) && - (!(node->st_flags&ST_FLG_DEF_NOEXPAND)) ); + (*iter)->setExpanded((node->parent==(&st->root)) && + (!(node->st_flags&ST_FLG_DEF_NOEXPAND))); g_free(valstrs); } node_count++; diff --git a/ui/qt/tcp_stream_dialog.cpp b/ui/qt/tcp_stream_dialog.cpp index 9f3fa9d91c..88e426b54a 100644 --- a/ui/qt/tcp_stream_dialog.cpp +++ b/ui/qt/tcp_stream_dialog.cpp @@ -766,7 +766,7 @@ void TCPStreamDialog::fillWindowScale() double ts = seg->rel_secs + seg->rel_usecs / 1000000.0; guint16 flags = seg->th_flags; - if ( (flags & (TH_SYN|TH_RST)) == 0 ) { + if ((flags & (TH_SYN|TH_RST)) == 0) { rel_time.append(ts - ts_offset_); win_size.append(seg->th_win); } diff --git a/ui/qt/traffic_table_dialog.cpp b/ui/qt/traffic_table_dialog.cpp index aea2fd66ad..4790e1ff94 100644 --- a/ui/qt/traffic_table_dialog.cpp +++ b/ui/qt/traffic_table_dialog.cpp @@ -100,9 +100,9 @@ TrafficTableDialog::~TrafficTableDialog() const QList TrafficTableDialog::defaultProtos() const { // Reasonable defaults? - return QList() << proto_get_id_by_filter_name( "eth" ) << proto_get_id_by_filter_name( "ip" ) - << proto_get_id_by_filter_name( "ipv6" ) << proto_get_id_by_filter_name( "tcp" ) - << proto_get_id_by_filter_name( "udp" ); + return QList() << proto_get_id_by_filter_name("eth") << proto_get_id_by_filter_name("ip") + << proto_get_id_by_filter_name("ipv6") << proto_get_id_by_filter_name("tcp") + << proto_get_id_by_filter_name("udp"); } void TrafficTableDialog::fillTypeMenu(QList &enabled_protos) diff --git a/ui/qt/wlan_statistics_dialog.cpp b/ui/qt/wlan_statistics_dialog.cpp index 3a21c92f8e..6ebf4b82ec 100644 --- a/ui/qt/wlan_statistics_dialog.cpp +++ b/ui/qt/wlan_statistics_dialog.cpp @@ -269,7 +269,7 @@ public: is_ssid_match = true; } if (is_bssid_match) { - if ((ssid_.isEmpty() || ssid_[0] == '\0') && (wlan_hdr->stats.ssid_len > 0) && (wlan_hdr->stats.ssid[0] != 0) ) { + if ((ssid_.isEmpty() || ssid_[0] == '\0') && (wlan_hdr->stats.ssid_len > 0) && (wlan_hdr->stats.ssid[0] != 0)) { update_ssid = true; } }