ui: Code cleanup

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 <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Stig Bjørlykke 2016-01-23 13:18:30 +01:00 committed by Anders Broman
parent dd46389485
commit 720f57d000
27 changed files with 188 additions and 227 deletions

View File

@ -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;
}
}

View File

@ -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<QStringList> *plugin_data = (QList<QStringList> *)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("<tr><td>%1</td><td>%2</td><td>%3</td><td>%4</td></tr>\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

View File

@ -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<BluetoothAttServerAttributesDialog *>(tapinfo->ui);

View File

@ -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<BluetoothDevicesDialog *>(tapinfo->ui);

View File

@ -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<BluetoothHciSummaryDialog *>(tapinfo->ui);

View File

@ -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;
}

View File

@ -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",

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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++ = ' ';
}

View File

@ -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;

View File

@ -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();

View File

@ -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);
}

View File

@ -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<QMenu*> lst;
if ( objectName.length() > 0 )
{
if (objectName.length() > 0) {
QString searchName = QString("menu") + objectName;
lst = main_ui_->menuBar->findChildren<QMenu*>();
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,

View File

@ -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<void *>())
{
if (v.canConvert<void *>()) {
entry = (ext_menubar_t *)v.value<void *>();
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();

View File

@ -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();

View File

@ -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_;

View File

@ -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();

View File

@ -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;

View File

@ -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...");

View File

@ -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");

View File

@ -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);

View File

@ -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;
}

View File

@ -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++;

View File

@ -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);
}

View File

@ -100,9 +100,9 @@ TrafficTableDialog::~TrafficTableDialog()
const QList<int> TrafficTableDialog::defaultProtos() const
{
// Reasonable defaults?
return QList<int>() << 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<int>() << 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<int> &enabled_protos)

View File

@ -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;
}
}